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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xsolla/xui-badge

v0.128.0-pr195.1775026924

Published

A cross-platform React badge component for displaying counts, status indicators, and small labels. Supports multiple sizes and color tones.

Downloads

7,974

Readme

Badge

A cross-platform React badge component for displaying counts, status indicators, and small labels. Supports multiple sizes and color tones.

Installation

npm install @xsolla/xui-badge
# or
yarn add @xsolla/xui-badge

Demo

Basic Badge

import * as React from 'react';
import { Badge } from '@xsolla/xui-badge';

export default function BasicBadge() {
  return (
    <div style={{ display: 'flex', gap: 16 }}>
      <Badge>5</Badge>
      <Badge>99+</Badge>
      <Badge>New</Badge>
    </div>
  );
}

Badge Tones

import * as React from 'react';
import { Badge } from '@xsolla/xui-badge';

export default function BadgeTones() {
  return (
    <div style={{ display: 'flex', gap: 16 }}>
      <Badge tone="primary">Primary</Badge>
      <Badge tone="secondary">Secondary</Badge>
      <Badge tone="brand">Brand</Badge>
      <Badge tone="brandExtra">Extra</Badge>
      <Badge tone="success">Success</Badge>
      <Badge tone="warning">Warning</Badge>
      <Badge tone="alert">Alert</Badge>
      <Badge tone="neutral">Neutral</Badge>
    </div>
  );
}

Badge Sizes

import * as React from 'react';
import { Badge } from '@xsolla/xui-badge';

export default function BadgeSizes() {
  return (
    <div style={{ display: 'flex', gap: 16, alignItems: 'center' }}>
      <Badge size="xs" tone="alert" /> {/* Dot only */}
      <Badge size="sm" tone="alert" />  {/* Dot only */}
      <Badge size="md" tone="alert">5</Badge>
      <Badge size="lg" tone="alert">5</Badge>
      <Badge size="xl" tone="alert">5</Badge>
    </div>
  );
}

Badge with Icon

import * as React from 'react';
import { Badge } from '@xsolla/xui-badge';
import { Check, AlertCircle } from '@xsolla/xui-icons';
import { Star } from '@xsolla/xui-icons-base';

export default function BadgeWithIcon() {
  return (
    <div style={{ display: 'flex', gap: 16 }}>
      <Badge icon={<Star size={12} />} tone="warning">Featured</Badge>
      <Badge icon={<Check size={12} />} tone="success">Verified</Badge>
      <Badge icon={<AlertCircle size={12} />} tone="alert">Error</Badge>
    </div>
  );
}

Dot Badge (Status Indicator)

import * as React from 'react';
import { Badge } from '@xsolla/xui-badge';

export default function DotBadge() {
  return (
    <div style={{ display: 'flex', gap: 16, alignItems: 'center' }}>
      <span>Online</span>
      <Badge size="xs" tone="success" />

      <span>Away</span>
      <Badge size="xs" tone="warning" />

      <span>Busy</span>
      <Badge size="xs" tone="alert" />

      <span>Offline</span>
      <Badge size="xs" tone="neutral" />
    </div>
  );
}

Anatomy

Import the component and use it directly:

import { Badge } from '@xsolla/xui-badge';

<Badge
  size="md"              // Size variant (xs/s are dots only)
  tone="alert"          // Color tone
  icon={<Icon />}       // Optional icon
  showStroke={false}    // Show border
>
  Content
</Badge>

Examples

Notification Count

import * as React from 'react';
import { Badge } from '@xsolla/xui-badge';
import { Bell } from '@xsolla/xui-icons';

export default function NotificationBadge() {
  const count = 12;

  return (
    <div style={{ position: 'relative', display: 'inline-block' }}>
      <Bell size={24} />
      <div style={{ position: 'absolute', top: -8, right: -8 }}>
        <Badge tone="alert" size="md">
          {count > 99 ? '99+' : count}
        </Badge>
      </div>
    </div>
  );
}

Badge with Stroke

import * as React from 'react';
import { Badge } from '@xsolla/xui-badge';

export default function BadgeWithStroke() {
  return (
    <div style={{ display: 'flex', gap: 16 }}>
      <Badge tone="brand" showStroke>Pro</Badge>
      <Badge tone="success" showStroke>Active</Badge>
    </div>
  );
}

Status Labels

import * as React from 'react';
import { Badge } from '@xsolla/xui-badge';

export default function StatusLabels() {
  const statuses = [
    { label: 'Published', tone: 'success' as const },
    { label: 'Draft', tone: 'neutral' as const },
    { label: 'Pending', tone: 'warning' as const },
    { label: 'Rejected', tone: 'alert' as const },
  ];

  return (
    <div style={{ display: 'flex', gap: 12 }}>
      {statuses.map((status) => (
        <Badge key={status.label} tone={status.tone} size="md">
          {status.label}
        </Badge>
      ))}
    </div>
  );
}

API Reference

Badge

A badge component for counts and status indicators.

Badge Props:

| Prop | Type | Default | Description | | :--- | :--- | :------ | :---------- | | children | ReactNode | - | Badge content (ignored for xs/s sizes). | | icon | ReactNode | - | Icon to display. | | size | "xl" \| "lg" \| "md" \| "sm" \| "xs" | "md" | Size of the badge. | | tone | "primary" \| "secondary" \| "brand" \| "brandExtra" \| "success" \| "warning" \| "alert" \| "neutral" | "alert" | Color tone. | | showStroke | boolean | false | Show border around badge. | | aria-label | string | - | Accessible label. | | aria-hidden | boolean | - | Hide from screen readers. |

Size Behavior:

| Size | Behavior | | :--- | :------- | | xs | Dot only (8px), no content | | sm | Dot only (12px), no content | | md | Supports content (20px height) | | lg | Supports content (24px height) | | xl | Supports content (28px height) |

Tone Color Mapping:

| Tone | Background | Text | | :--- | :--------- | :--- | | primary | Background primary | Content primary | | secondary | Background secondary | Content primary | | brand | Brand primary | On brand | | brandExtra | BrandExtra primary | On brandExtra | | success | Success primary | On success | | warning | Warning primary | On warning | | alert | Alert primary | On alert | | neutral | Neutral primary | On neutral |

Theming

Badge uses the design system theme for colors:

// Colors accessed via theme (example for "alert" tone)
theme.colors.background.alert.primary  // Background
theme.colors.content.onAlert           // Text color

Accessibility

  • Uses role="status" for proper semantics
  • Dot badges without labels use aria-hidden by default
  • Supports custom aria-label for screen readers
  • Text content is automatically announced