Badge
A compact label for status, categories and short counters.
Installation
Shadwire follows shadcn/ui's open code model: the component's source is copied into your application and becomes yours. Install it with the CLI:
The badge registry item installs these files:
-
app/components/ui_component.rb -
app/components/ui/badge_component.rb -
app/helpers/ui/badge_helper.rb -
vendor/shadwire/shadwire.css
Haven't installed the CLI yet? gem install shadwire, then shadwire init.
Usage
Or render Ui::BadgeComponent directly:
Examples
Variants
Use variants to signal priority, state or category.
Badge
Secondary
Destructive
Outline
API reference
ui_badge(**options, &block) wraps Ui::BadgeComponent.new(**options).
| Argument | Type | Default | Description |
|---|---|---|---|
variant | Symbol/String | :default | :default, :secondary, :destructive or :outline. |
tag | Symbol | :span | The element to render; :a with href: for a badge that links. Hover styles apply to links only. |
class / class_name | String | nil | Extra classes. |
**attrs | Hash | {} | Free-form HTML attributes for the element. |