Skip to content

Badge

A small label for status or counts, in the neutral, brand, success, warning or danger colours.

// Plain markup
import { Badge } from "@shavin/ui";

Variants

variant sets the fill. The default is surface.

SurfaceOutlineSoftSolid
Component Source
<Badge variant="surface" tone="brand">Surface</Badge>
<Badge variant="outline" tone="brand">Outline</Badge>
<Badge variant="soft" tone="brand">Soft</Badge>
<Badge variant="solid" tone="brand">Solid</Badge>

Tones

tone sets the meaning. The default is neutral.

DraftSharedPaidDue soonOverdue
Component Source
<Badge variant="soft" tone="neutral">Draft</Badge>
<Badge variant="soft" tone="brand">Shared</Badge>
<Badge variant="soft" tone="success">Paid</Badge>
<Badge variant="soft" tone="warning">Due soon</Badge>
<Badge variant="soft" tone="danger">Overdue</Badge>

Sizes

sm, md (default) and lg.

SmallMediumLarge
Component Source
<Badge tone="brand" size="sm">Small</Badge>
<Badge tone="brand" size="md">Medium</Badge>
<Badge tone="brand" size="lg">Large</Badge>

Radius

The default, inherit, follows the theme radius. Fixed values ignore it. concentric matches the radius of the panel the badge sits in.

NoneSmallMediumLargeFullInherit (default)
Component Source
<Badge tone="brand" radius="none">None</Badge>
<Badge tone="brand" radius="small">Small</Badge>
<Badge tone="brand" radius="medium">Medium</Badge>
<Badge tone="brand" radius="large">Large</Badge>
<Badge tone="brand" radius="full">Full</Badge>
<Badge tone="brand" radius="inherit">Inherit (default)</Badge>

With an icon

icon renders before the label.

PaidDue tomorrow
Component Source
<Badge variant="soft" tone="success" icon={<Icon name="check" size="xs" />}>Paid</Badge>
<Badge variant="soft" tone="warning" icon={<Icon name="clock" size="xs" />}>Due tomorrow</Badge>

In context

Streaming subscription

Due tomorrow

Car loan

Paid
Component Source
<Flex align="center" gap="2">
  <Text size="sm">Streaming subscription</Text>
  <Badge variant="soft" tone="warning">Due tomorrow</Badge>
</Flex>
<Flex align="center" gap="2">
  <Text size="sm">Car loan</Text>
  <Badge variant="soft" tone="success">Paid</Badge>
</Flex>

The color prop

Older code passes color. It still works as an alias for tone. When you set a color other than neutral and no variant, the badge uses the soft variant. New code should use tone and variant.

Props

PropTypeDefaultDescription
color"neutral" | "brand" | "success" | "warning" | "danger"—@deprecated Backward compatible alias of `tone`. Use `tone`.
iconReact.ReactNode—Optional icon node rendered before label.
variant"surface" | "outline" | "soft" | "solid""surface"—
tone"neutral" | "brand" | "success" | "warning" | "danger""neutral"—
size"sm" | "md" | "lg""md"—
radius"none" | "small" | "medium" | "large" | "full" | "inherit" | "concentric""inherit"—
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font