npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@droid-tech/react-ts-badge

v0.0.1

Published

A simple React TypeScript badge component

Downloads

6

Readme

Badge Component

The Badge component is a versatile React component that adds a small badge to its child content. It's built with TypeScript, providing type safety and easy integration into React projects.

Features

  • Two variants: dot and standard
  • Customizable badge content
  • Flexible positioning
  • Color customization
  • Invisible mode
  • Maximum value display
  • Blinking animation option
  • TypeScript support for type safety

Installation

To use the Badge component in your React application, install it via npm:

npm install @droid-tech/react-ts-badge

Usage

To use the Badge component, import it and wrap it around the content you want to badge:

import Badge from "@droid-tech/react-ts-badge";

const MyComponent = () => {
  return (
    <Badge badgeContent={4}>
      <YourComponent />
    </Badge>
  );
};

Props

The Badge component accepts the following props:

| Prop | Type | Default | Description | |----------------|--------------------------------------------------------------|---------------|----------------------------------------------------| | variant | 'dot' \| 'standard' | 'standard' | The variant of the badge | | badgeContent | React.ReactNode | - | The content of the badge | | color | string | '#fff' | The text color of the badge | | bgcolor | string | '#bdbdbd' | The background color of the badge | | position | 'top-right' \| 'bottom-right' \| 'bottom-left' \| 'top-left' | 'top-right' | The position of the badge | | anchorOrigin | 'top-right' \| 'bottom-right' \| 'bottom-left' \| 'top-left' | 'top-right' | The anchor point for the badge | | invisible | boolean | false | Whether the badge should be invisible | | max | number | 99 | The maximum value to display | | blink | boolean | false | Whether the badge should blink | | children | React.ReactNode | - | The content to be badged |

Customization

Variants

The Badge component supports two variants:

  1. 'standard': A rounded rectangle badge with content
  2. 'dot': A small circular badge without content
<Badge variant="dot" badgeContent={''}>
  <YourComponent />
</Badge>

Colors

You can customize the text color and background color of the badge:

<Badge badgeContent={4} color="#ffffff" bgcolor="#ff0000">
  <YourComponent />
</Badge>

Position

You can adjust the position of the badge:

<Badge badgeContent={4} position="bottom-left">
  <YourComponent />
</Badge>

Maximum Value

You can set a maximum value for numeric content:

<Badge badgeContent={1000} max={999}>
  <YourComponent />
</Badge>

This will display as "999+" for any value over 999.

Blinking Animation

You can make the badge blink:

<Badge badgeContent={4} blink={true}>
  <YourComponent />
</Badge>

Accessibility

The Badge component is designed to be accessible, providing visual feedback for notifications or status indicators. However, ensure that you're also providing alternative ways for users to access this information for better accessibility.

Conclusion

The Badge component provides a flexible and customizable way to add badges to elements in your React application. With its various customization options and TypeScript support, it can easily be integrated into your project to provide visual indicators for notifications, status, or other information.