Badge
A short status word or count.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsstable
- 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
| Prop | Type | Default | Description |
|---|---|---|---|
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
| Class | Stylesheet |
|---|---|
.badge | 05-marks.css |
.badge-accent | 05-marks.css |
.badge-solid | 05-marks.css |
.check | 05-marks.css |
.check-fail | 05-marks.css |
.check-pass | 05-marks.css |
.dot | 05-marks.css |
.heat-0 | 05-marks.css |
.heat-1 | 05-marks.css |
.heat-2 | 05-marks.css |
.heat-3 | 05-marks.css |
.heat-4 | 05-marks.css |
.kbd | 05-marks.css |
.key-hints | 05-marks.css |
.swatch | 05-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.