Skip to content

Badge

Badge is used to indicate statuses, notifications, or counts associated with other UI elements.

Import

import { Badge } from "@cfa/react-core";

Live Editor

Examples

Color

There are two colors: "primary" as default, and "secondary".

Border

Pass border to add a border to the Badge.

Placement

There are four placement options: "topRight" as default and "topLeft" | "bottomRight" | "bottomLeft".

Large Content

It is recommended to use a ”+” for any content value larger than two digits.

Controlled / Toggle

Use the hide prop to control the state of the Badge. The Badge will animate-in when hide={true} and animate-out when set to false.

Props

Visit the Documentation Site for the full list of props.

NameTypeDefaultDescription
badgeContentReactNode-The Badge content, primarily a number 0-99(+).
borderbooleanfalseChange the border of Badge to white.
childrenReactNode-The content or child elements nested within this component.
classNamestring-CSS class names to apply custom styling.
color"primary" | "secondary""primary"The background color of the Badge.
hidebooleanfalseSet to true, to hide the component. Useful when toggling on/off.
idstring-The unique identifier for the DOM element.
placement"topRight" | "topLeft" | "bottomRight" | "bottomLeft""topRight"The placement of the Badge in relation to its children anchor.
roleAriaRole-The ARIA role assigned to the element to improve accessibility. Example roles include "button", "navigation", "dialog", etc.
styleCSSProperties-Inline styles specified as a React-compatible CSS properties object.