Badge
A count or status badge floating at the top-right corner of its child.
Basic usage
Basic usage
599+0
import { LhBadge, LhButton } from '@lh-ui/react'
export default function Demo() {
return (
<>
<LhBadge value={5}>
<LhButton>Messages</LhButton>
</LhBadge>
<LhBadge value={120} max={99}>
<LhButton>Replies</LhButton>
</LhBadge>
<LhBadge isDot>
<LhButton>Notifications</LhButton>
</LhBadge>
</>
)
}
Badge Props
| Prop | Description | Type | Options | Default |
|---|---|---|---|---|
| type | Badge type (color) | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default' | — | 'danger' |
| value | Value to display; numbers above max render as max+, non-numeric strings render verbatim | string | number | — | — |
| size | Size | 'mini' | 'small' | 'medium' | 'large' | 'x-large' | — | 'medium' |
| max | Cap for numeric value | number | — | 99 |
| isDot | Render a dot only (no content; the dot is hidden from screen readers) | boolean | — | false |
| hidden | Whether the badge is hidden | boolean | — | false |
| offset | Badge offset [x, y] (pixels relative to the default position) | [number, number] | — | — |
| showZero | Whether a value of 0 still renders | boolean | — | false |
| content | Custom badge content (takes precedence over value) | string | — | — |
| sx | Layout shorthand | SxProps | — | — |
Vue equivalent
value / max / isDot / hidden / showZero / content / offset match lh-ui-plus's
LhBadge props; React has no slots, so the wrapped element is passed as children.
Accessibility
In isDot mode the dot is purely decorative and outputs aria-hidden, so screen readers skip
it; text badges are read aloud — keep value / content meaningful.
Styles
import '@lh-ui/react/style/badge'