Components
Count
A number in a pill: how many of something there are.
3471284,210
import { Count } from '@dex/shared/components/count'
export function CountDefault() {
return (
<>
<Count value={3} />
<Count value={47} />
<Count value={128} />
<Count value={4210} />
</>
)
}
12052
import { Count } from '@dex/shared/components/count'
export function CountTones() {
return (
<>
<Count value={12} />
<Count tone="muted" value={0} />
<Count tone="strong" value={5} />
<Count tone="danger" value={2} />
</>
)
}
5522
import { Count } from '@dex/shared/components/count'
export function CountSizes() {
return (
<>
<Count size="sm" value={5} />
<Count value={5} />
<Count size="sm" tone="danger" value={2} />
<Count tone="danger" value={2} />
</>
)
}
4299+9+
import { Count } from '@dex/shared/components/count'
export function CountWithLimit() {
return (
<>
<Count max={99} value={42} />
<Count max={99} value={128} />
<Count max={9} size="sm" tone="danger" value={12} />
</>
)
}
- A count holds a number and nothing else: how many are in a queue, on a tab, waiting for a reply. A label with words in it is a badge.
- It shows the full number, with thousands grouped. Set
maxonly where there is no room for more digits, and it shows the limit with a plus. neutralby default.mutedat zero, so the rows that have work stand out.dangerfor something waiting on the reader, such as replies not yet read.strongsparingly.- Put it next to the thing it counts, and give it an
aria-labelwhere the number alone would not make sense read out, such as "2 replies waiting". - Use
smon something small, such as a tab or a segment.