Badge
To display a badge, wrap text in a <Badge>.
import { Badge } from "stylus-ui/Badge";
export default () => <Badge>New</Badge>;Different colors of badges can be displayed by setting the variant.
import { Badge } from "stylus-ui/Badge";
export default () => ( <div className="flex gap-2"> <Badge>Default</Badge> <Badge variant="info">Info</Badge> <Badge variant="success">Success</Badge> <Badge variant="warning">Warning</Badge> <Badge variant="error">Error</Badge> <Badge variant="brand">Brand</Badge> </div>);Icons can be displayed within a badge by importing and passing a Font Awesome icon.
import { Badge } from "stylus-ui/Badge";import { faCheck } from "@fortawesome/pro-regular-svg-icons";
export default () => ( <Badge variant="success" icon={faCheck}> Verified </Badge>);End Icons
Section titled “End Icons”import { Badge } from "stylus-ui/Badge";import { faSparkle } from "@fortawesome/pro-regular-svg-icons";
export default () => ( <Badge variant="brand" iconEnd={faSparkle} size="lg"> Translated by AI </Badge>);Sizing
Section titled “Sizing”Badges can be either small (default), or large.
import { Badge } from "stylus-ui/Badge";import { faCheck } from "@fortawesome/pro-regular-svg-icons";
export default () => ( <div className="flex items-center gap-2"> <Badge icon={faCheck}>Small</Badge> <Badge icon={faCheck} size="lg"> Large </Badge> </div>);Placement
Section titled “Placement”Place a badge above, below, or to either side of the element it labels — never floating over it. Badges are transparent, so overlapping elements will bleed through.
import { Badge } from "stylus-ui/Badge";import { Button } from "stylus-ui/Button";import { faLocationArrow } from "@fortawesome/pro-regular-svg-icons";
<Button variant="secondary" icon={faLocationArrow}> Guide Me <Badge variant="brand" size="sm"> Beta </Badge></Button>;API Reference
Section titled “API Reference”A small, enclosed text element used to represent status.
icon
Icon shown before the label.
iconClassName
Classes applied to the start icon.
iconEnd
Icon shown after the label.
iconEndClassName
Classes applied to the end icon.
size
Height and padding: sm (compact) or lg.
theme
Theme for contrast; affects icon color when set.
variant
Background and text color: default (gray), info, success, warning, error, or brand.