Playground

Badge

A short status word or count.

  • Built on native elements
  • Plain text in a span; the word carries the meaning, not the colour.
  • For a count that changes, put it inside an aria-live region yourself.
  • Styles in one file: 05-marks.css

Import

import '@monoline/css';
import {Badge} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add badge

Usage

import {Badge} from '@monoline/react';

<div style={{display: 'flex', gap: 'var(--s3)', flexWrap: 'wrap'}}>
  <Badge>draft</Badge>
  <Badge variant="solid">12 days</Badge>
  <Badge variant="accent">new</Badge>
</div>

Examples

Variants

Props

BadgeProps

PropTypeDefaultDescription
variant"solid" | "outline" | "accent"'outline'`accent` only for "new" or "now".

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.badge05-marks.css
.badge-accent05-marks.css
.badge-solid05-marks.css
.check05-marks.css
.check-fail05-marks.css
.check-pass05-marks.css
.dot05-marks.css
.heat-005-marks.css
.heat-105-marks.css
.heat-205-marks.css
.heat-305-marks.css
.heat-405-marks.css
.kbd05-marks.css
.key-hints05-marks.css
.swatch05-marks.css

Customization

Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.

app.css
.badge {
  border-color: var(--accent);
}

Try the props

Change a prop and the component above updates; the code below is what you would write. To edit the code itself, use the Playground.

New
example.tsx
<Badge>New</Badge>

Accessibility

  • Plain text in a span; the word carries the meaning, not the colour.
  • For a count that changes, put it inside an aria-live region yourself.