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
| Name | Type | Default | Description |
|---|---|---|---|
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.