Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Feedback and display

Badge

A small status or category label in the mono "eyebrow" style. It only labels; it does nothing when clicked. For an action use Button.

Every tone and variant is readable

When to useLink to "When to use"

  • Status: Saved, Failed, Pending.
  • Category or type: node kinds, column types, plan names.
  • soft (default): the quiet choice for lists and tables.
  • solid: a status that must stand out. outline: a label in busy or tinted surroundings.

Use something else when:

UsageLink to "Usage"

tsx
Copy
import { Badge } from "@arshad-shah/cynosure";
import { check } from "@arshad-shah/cynosure/icons";

<Badge tone="success" icon={check}>Saved</Badge>
<Badge tone="danger" variant="solid">Failed</Badge>
<Badge size="sm" variant="outline">Beta</Badge>

Tone, variant and sizeLink to "Tone, variant and size"

tone is accent, neutral (default), danger, success, warning or info. variant is soft, solid or outline. size is sm, md or lg. An optional icon sits before the text. Every tone and variant keeps text at 4.5:1 or better (tested).

Tone carries meaning, but keep the text meaningful too: don't rely on colour alone to say "failed".

Status dotLink to "Status dot"

dot adds a dot before the text: true for a steady one, "live" for a pulsing one (recording, connected). Leave the text out for a dot alone, in the tone's own colour with no pill around it. It is then an image named by label, since colour alone says nothing. Where text beside it already says the state, leave label out: the dot is then decoration, hidden from assistive technology.

tsx
Copy
<Badge tone="success" dot label="Connected" />
<Badge tone="danger" dot="live" label="Recording" />
Dot without text

PropsLink to "Props"

Every prop of Badge
PropWhat it doesTypeDefault
tone
Semantic colour. Default "neutral".Tone"neutral"
variant
Fill style. Default "soft"."soft" | "solid" | "outline""soft"
size
Size of the badge. Default "md".Size"md"
icon
Icon shown before the text.IconData
color
A category colour (any CSS colour), for labels a product colours itself (HTTP methods, calendar categories). The text is mixed toward the ink so it stays readable. Overrides tone.string
dot
A dot before the text: true for a steady one, "live" for a pulsing one (recording, connected).boolean | "live"
className
Added to the root element, for layout.string
style
Layout only.CSSProperties
children
The badge's text. Leave it out, with dot, for a status dot alone.ReactNode
label
Accessible name of a dot without text; a badge with text is named by its text. Accessible name of a dot without text, saying the state ("Connected"): colour alone says nothing. Leave it out only where text beside the dot already says the state: the dot is then decoration, hidden from assistive technology.string

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

ThemingLink to "Theming"

Tokens: --cy-badge-radius, --cy-badge-tracking and --cy-badge-soft-mix.

ts
Copy
createTheme({ components: { badge: { radius: "999px", tracking: "0.04em" } } });

className and style are for layout only.

Button · Link · Inline

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog