Skip to content

Badge

Label status, counts and metadata in a compact badge.

import { Badge, BadgeDot, BadgeRemove } from '@youj/react'

Installation & usage

npm i @youj/react

For an app already set up with npx @youj/cli init, which installs the peers (@youj/core, @youj/motion, motion and Base UI) and wires the provider. New app? Start at Installation.

Use Badge for short labels such as status, count, version or environment. Keep it non-interactive or make it a link. Use a button for actions, and an Alert or Toast for longer messages.

import { Badge } from '@youj/react'

export function Status() {
  return <Badge variant="success">Ready</Badge>
}

Reference

Propsvariant (1)

Props

Badge props
PropType
variant'default' | 'neutral' | 'success' | 'warning' | 'danger' | 'solid' | 'outline' | 'secondary'

default 'default'

'default'
size'default' | 'sm' | 'lg'

sm (18px) for a count or tag in a dense row, lg (24px) beside a title.

default 'default'

'default'
colorstring

A colour of your own for a label chip, in place of the variant's: a theme colour's name (chart-1…chart-5, accent, info, success, warning, danger) or any CSS colour (var(--brand)). The chip is tinted with it and its text inked from it. A CSS colour's contrast is yours to check.

–

render comes from Base UI's useRender. It replaces the default span with your element and merges the badge's props onto it.

Reduced motionBadge doesn't move

Reduced motion

Badge doesn't move. A link badge's hover tint is a color change, and it stays under reduced motion.

Accessibilityfocus

Accessibility

  • A badge is plain text in a span, so it's read in line with its surroundings. Put it where the words make sense in reading order, such as after the item it describes.
  • Don't rely on color alone. The label carries the meaning, and an icon can reinforce it.
  • A link badge is a real a with a visible focus ring. Its text should say where it goes.