Dashral Pro is hereSee pricing

Dashral

IndicatorNew

A dot or a count on the corner of a button, an avatar or a tab.

$ pnpm dlx shadcn@latest add @dashral/indicator
3 unread notifications128 messagesFilters onNew mail arriving

Installation

$ pnpm dlx shadcn@latest add @dashral/indicator

Adds the component, the components it builds on, its npm packages and the theme tokens it uses. Or by its full URL: https://dashral.com/r/indicator.json

Usage

example.tsx
import { Button } from "@/components/dashral/button"
import { BellIcon } from "lucide-react"
import { Indicator } from "@/components/dashral/indicator"

<Indicator count={unread} label={`${unread} unread`}>
  <Button variant="outline" size="icon" aria-label="Notifications"><BellIcon /></Button>
</Indicator>

Using the npm package? Import from @dashral/ui/components/indicator instead, here and in the examples; the rest is the same.

Examples

On avatars

shape="round" sets it on the edge; position picks the corner.

MPMaya Pratama2 mentionsANArif NugrohoOnlineSDSinta DewiNeeds review

Coming and going

The count rises as notifications arrive and hides when they're read, scaling in and out on the spring.

1 unread notifications

API reference

Indicator

Also takes every prop of <span>(opens in a new tab).

PropTypeDefault
childrenReactNode

What it sits on: an icon button, an avatar, a tab. Required.

—
countnumber

A number in a small badge; without it, a dot. 0 hides it.

—
maxnumber

Above this, "99+".

99
showZeroboolean

Show the badge at 0.

false
showboolean

Whether it shows; it scales in and out.

true
color"primary" | "neutral" | "info" | "success" | "warning" | "destructive" | "highlight"

Its fill.

"destructive"
position"top-end" | "bottom-end" | "top-start" | "bottom-start"

Which corner (logical, so it mirrors in Arabic).

"top-end"
shape"square" | "round"

round: for a round element, so it sits on the edge rather than off the corner.

"square"
pulseboolean

A ring pulsing out from it.

false
labelstring

What it means, for screen readers: "3 unread". Without it, it's decoration.

—
classNames{ indicator }

The dot's classes, e.g. "ring-card" on a card.

—
classNamestring

Extra classes, merged with cn() so yours win.

—

Accessibility

  • With label, screen readers hear the label (the number is hidden from them); without it, the whole thing is hidden, so put the meaning in the element's own name.
  • The count is written in the locale's digits.

Motion

  • Scales in and out from its centre on the spring when show or count changes; pulse is a ping that's still with reduced motion.