Documentation
Feedback
Guides
Storefront Development

Storefront Development
Storefront development
Badge

Status descriptors used to emphasize an item's state.

The Badge component is used to emphasize an item's state by displaying concise, non-interactive labels. Typical use cases include:
  • Highlighting promotional discounts
  • Indicating product features (e.g., vegan or cruelty-free)
  • Displaying availability statuses (e.g., NEW, ONLY 1 LEFT, and OUT OF STOCK)
Example
Code
Neutral
Info
Highlighted
Neutral & Big
Success
Warning
Danger

Usage

Import the component


_10
import { Badge } from "@faststore/ui";

Import styles

To apply styles, include the following in your stylesheet:

_10
@import "@faststore/ui/src/components/atoms/Badge/styles.scss";


Examples

Size

The Badge component can be displayed in two sizes: small (default) and big.

Small (Default)

Example
Code
Small Badge

Big

Example
Code
Big Badge

Variants

Neutral

Example
Code
Neutral Badge

Success

Example
Code
Success Badge

Highlighted

Example
Code
Highlighted Badge

Info

Example
Code
Info Badge

Warning

Example
Code
Warning Badge

Danger

Example
Code
Danger Badge

Design tokens

Local tokenDefault value/Global token linked
--fs-badge-paddingvar(--fs-spacing-0) var(--fs-spacing-2)
--fs-badge-border-radiusvar(--fs-border-radius-pill)
--fs-badge-border-width0
--fs-badge-border-stylenone
--fs-badge-border-color
transparent
--fs-badge-bkg-color
var(--fs-color-neutral-bkg)
--fs-badge-text-color
var(--fs-color-text)
--fs-badge-text-sizevar(--fs-text-size-tiny)
--fs-badge-text-weightvar(--fs-text-weight-bold)
--fs-badge-transition-functionvar(--fs-transition-function)
--fs-badge-transition-propertyvar(--fs-transition-property)
--fs-badge-transition-timingvar(--fs-transition-timing)

Design tokens: Big

Big badges use increased padding and typography to create a more prominent and impactful component, suitable for key highlights or calls to action.
Local tokenDefault value/Global token linked
--fs-badge-big-text-sizevar(--fs-text-size-legend)
--fs-badge-big-paddingvar(--fs-spacing-1) var(--fs-spacing-2)

Design tokens: Neutral

Neutral badges present information in a low-contrast style, ideal for secondary statuses or default states.
Local tokenDefault value/Global token linked
--fs-badge-neutral-bkg-color
var(--fs-color-neutral-bkg)
--fs-badge-neutral-text-color
var(--fs-badge-text-color)
--fs-badge-neutral-border-color
var(--fs-color-neutral-bkg)

Design tokens: Success

Success badges use a green palette to confirm actions and indicate favorable outcomes.
Local tokenDefault value/Global token linked
--fs-badge-success-bkg-color
var(--fs-color-success-bkg)
--fs-badge-success-text-color
var(--fs-badge-text-color)
--fs-badge-success-border-color
var(--fs-color-success-bkg)

Design tokens: Highlighted

Highlighted badges draw attention with a high-contrast color scheme, which is ideal for promotions or featured items.
Local tokenDefault value/Global token linked
--fs-badge-highlighted-bkg-color
var(--fs-color-highlighted-bkg)
--fs-badge-highlighted-text-color
var(--fs-color-highlighted-text)
--fs-badge-highlighted-border-color
var(--fs-color-highlighted-bkg)

Design tokens: Info

Info badges use a blue palette to communicate neutral but helpful information, guidance, or notifications.
Local tokenDefault value/Global token linked
--fs-badge-info-bkg-color
var(--fs-color-info-bkg)
--fs-badge-info-text-color
var(--fs-color-info-text)
--fs-badge-info-border-color
var(--fs-color-info-bkg)

Design tokens: Warning

Warning badges use an orange or yellow palette to signal caution, pending actions, or non-critical alerts.
Local tokenDefault value/Global token linked
--fs-badge-warning-bkg-color
var(--fs-color-warning-bkg)
--fs-badge-warning-text-color
var(--fs-color-warning-text)
--fs-badge-warning-border-color
var(--fs-color-warning-bkg)

Design tokens: Danger

Danger badges use a red palette to warn users of critical errors, destructive actions, or important failures.
Local tokenDefault value/Global token linked
--fs-badge-danger-bkg-color
var(--fs-color-danger-bkg)
--fs-badge-danger-text-color
var(--fs-badge-text-color)
--fs-badge-danger-border-color
var(--fs-color-danger-bkg)

Data attributes

You can target and override Badge styles using the following data attributes:
data-fs-badge
data-fs-badge-size="small" | "big"
data-fs-badge-variant="info" | "highlighted" | "success" | "neutral" | "warning" | "danger"

Props

NameTypeDescriptionDefault
testIdstringID to find this component in testing tools (e.g.: cypress, testing library, and jest).fs-badge
size"small" | "big"Specifies the size variant.small
variant"info" | "highlighted" | "success" | "neutral" | "warning" | "danger"Specifies the component variant.neutral
counterfalse | trueEnables counter badge.false
aria-labelstringFor accessibility purposes, adds an ARIA label to the element when `counter` is set to `true`.

Best practices

✅ Do's

  • Place the badge next to or on top of its related item.
  • Be cautious about the badge's positioning, text, shape, and color to avoid any confusion with components similar in appearance.
  • Ensure sufficient text contrast against the background.

❌ Don'ts

  • Don't use long text in badges. A reasonable character limit is 15.
  • Don't label badges with active verbs.
  • Don't rely on color alone to convey meaning. Ensure there is a text alternative for that meaning as well.
  • Don't place badges next to buttons, as badges are not interactive and could confuse users.

Contributors
2
Photo of the contributor
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
2
Photo of the contributor
Photo of the contributor
On this page