Skip to content

Indicator

A small dot or pill that decorates another element — unread counts on icons, status dots on avatars, "new" markers on nav items. Wraps any single child without changing its layout.

  • stable
  • since v0.1.0
  • 0.8 kB
  • feedback
  • status

Pass aria-label (e.g. "3 unread messages") when the indicator conveys information not present elsewhere in the DOM. The wrapped child stays the primary interactive target.

Preview
Open
tsx

Set dot to drop the content and render a small filled dot — the right fit for “has activity” / online-status decorations on avatars and nav icons.

Preview
Open
tsx

colorScheme accepts accent, success, warning, danger, info, neutral. Pair semantics with colour: danger for unread / critical, success for online, warning for attention, accent for new / featured.

Preview
Open
tsx

placement accepts top-start, top-end (default), bottom-start, bottom-end. Use offset to nudge the indicator inward when it should sit inside the child rather than spilling over the edge.

Preview
Open
tsx
PropTypeDefaultDescription
content
ReactNode
Content rendered inside the badge. Omit for dot mode.
dot
boolean
false
Render as a bare coloured dot rather than a content badge.
placement
"top-start"|"top-end"|"bottom-start"|"bottom-end"
top-end
Corner the badge hugs. One of `top-start`, `top-end`, `bottom-start`, `bottom-end`.
offset
number
0
Inset offset in pixels. Positive values push the badge further outside the child.
invisible
boolean
Hide the badge entirely while preserving layout.
hideOn
((content: ReactNode) => boolean)
Predicate variant of `invisible`, evaluated against `content`.
colorScheme
"accent"|"neutral"|"success"|"warning"|"danger"|"info"
neutral
Palette forwarded to the inner badge. One of `neutral`, `accent`, `success`, `warning`, `danger`, `info`.
variant
"solid"|"soft"|"outline"|"ghost"
solid
Visual style forwarded to the inner badge. One of `soft`, `solid`, `outline`, `ghost`.
size
"xs"|"sm"|"md"
xs
Pixel scale forwarded to the inner badge.
icon
ReactNode
Icon rendered inside the badge alongside `content`.
children*
ReactElement<unknown, string | JSXElementConstructor<any>>
The element the indicator decorates. Exactly one React element.
aria-label
string
Override screen-reader label. When omitted and `content` is a string or number, the content is announced; in pure dot mode the indicator is marked decorative.
  • Unread count on an icon button: <Indicator content={count} colorScheme="danger" hideOn={(c) => !c}><IconButton ... /></Indicator> — the hideOn predicate keeps the indicator off the DOM when the count is zero.
  • Avatar online status: <Indicator dot colorScheme="success" placement="bottom-end"><Avatar ... /></Indicator>.
  • Always pair counts with an aria-label describing the meaning so AT users get more than just the number.