Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

Badge

A small badge that displays a status or label.

View in Storybook (opens in a new tab)

Installation

import { Badge } from "@ginga-ui/core";

Basic usage

A simple badge example.

New
badge.tsx
import { Badge } from "@ginga-ui/core";

export function BasicExample() {
  return <Badge>New</Badge>;
}

Variants

Six variants are available: primary, secondary, info, success, warning, and danger.

PrimarySecondaryInfoSuccessWarningDanger
badge.tsx
badge.module.css
import { Badge } from "@ginga-ui/core";
import styles from "./badge.module.css";

export function VariantsExample() {
  return (
    <div className={styles.badgeRow}>
      <Badge variant="primary">Primary</Badge>
      <Badge variant="secondary">Secondary</Badge>
      <Badge variant="info">Info</Badge>
      <Badge variant="success">Success</Badge>
      <Badge variant="warning">Warning</Badge>
      <Badge variant="danger">Danger</Badge>
    </div>
  );
}

With text

Show a count or similar value next to text.

You have notifications3

badge.tsx
badge.module.css
import { Badge } from "@ginga-ui/core";
import styles from "./badge.module.css";

export function WithTextExample() {
  return (
    <p className={styles.notification}>
      You have notifications
      <Badge variant="danger">3</Badge>
    </p>
  );
}

Props

Badge

NameTypeDefaultDescription
variant"primary" | "secondary" | "info" | "success" | "warning" | "danger""primary"Color variant of the badge.
render(props) => ReactElement-Replaces the root element. Return an element that receives the given props, such as next/link.

Also accepts the attributes of the HTML span (opens in a new tab) element.