Skip to main content

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​

PropDescriptionTypeOptionsDefault
typeBadge type (color)'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default'—'danger'
valueValue to display; numbers above max render as max+, non-numeric strings render verbatimstring | number——
sizeSize'mini' | 'small' | 'medium' | 'large' | 'x-large'—'medium'
maxCap for numeric valuenumber—99
isDotRender a dot only (no content; the dot is hidden from screen readers)boolean—false
hiddenWhether the badge is hiddenboolean—false
offsetBadge offset [x, y] (pixels relative to the default position)[number, number]——
showZeroWhether a value of 0 still rendersboolean—false
contentCustom badge content (takes precedence over value)string——
sxLayout shorthandSxProps——
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'