Badge

Badge is a small label that carries a status, a count or a category beside the thing it describes.

Installation

Nothing to add. This component ships as source in your download, so it is already in your project.

Filesrc/vui/badge.tsx
Import from@viliha/vui-react/badge

The exported names are at the top of that file. The import path is an alias the download's tsconfig.json points at src/vui/, so you can move that folder and change one line rather than every file that imports from it.

Usage

badge-demo.tsx
import { Badge } from "@viliha/vui-react/badge";

Exports

Everything this family exports. They are read from the source, so this list is what the package actually ships.

PropTypeDefault
Badgecomponent—

Badge props

Plus everything React.HTMLAttributes<HTMLSpanElement> accepts, passed straight through to the underlying element.

PropTypeDefaultWhat it does
variant?BadgeVariant"default"
solid?boolean—Paint the state's colour as the ground instead of a wash of it.
size?keyof typeof BADGE_SIZES—Omit to inherit the surrounding type size, which is what a badge in a table cell wants.

Customize

Every value this component draws comes from the theme: the colours, the radius, the control height and the type scale. Change a token and this moves with everything else, which is the difference between theming the product and overriding a component. See Theming for the token contract, and Swapping defaults for replacing the markup itself.