Badge
Small, circular or pill-shaped indicators for status, counts, or labels. Badges scale to match the size of the immediate parent element by using relative font sizing and em units.
Bootstrap Reference
Quick Start
Visual Examples & Use Cases
1. Variants
Like buttons, badges use semantic variants for meaning.
Code & Output
Live Preview
Success
Danger
Warning
Light
2. Contextual Badges
Badges are often placed inside other components like Buttons or Headings.
Live Preview
Documentation Beta
Practical Functionality
1. Indicators (Dot Style)
You can create "status dots" by using a Badge with no text and specific width/height.
# A small 'Online' green dot
Badge(variant="success", rounded=True, style={"width": "10px", "height": "10px", "padding": "0"})
Advanced Customization
1. CSS Variables
Customize standard badge colors.
| CSS Variable | Description | Default |
|---|---|---|
--bs-badge-padding-x |
Horizontal padding. | .65em |
--bs-badge-padding-y |
Vertical padding. | .35em |
--bs-badge-font-size |
Text size. | .75em |
--bs-badge-font-weight |
Boldness. | 700 |
--bs-badge-border-radius |
Corner roundness. | var(--bs-border-radius) |
Parameter Reference
| FastStrap Param | Type | Bootstrap Class | Description |
|---|---|---|---|
variant |
str |
.text-bg-{variant} |
Color theme. |
pill |
bool |
.rounded-pill |
Fully rounded edges. |
rounded |
bool |
.rounded-circle |
Perfect circle (if width=height). |
faststrap.components.display.badge.Badge(*children, variant=None, pill=None, **kwargs)
Bootstrap Badge component for status indicators and labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*children
|
Any
|
Badge content (text, numbers, icons) |
()
|
variant
|
VariantType | None
|
Bootstrap color variant |
None
|
pill
|
bool | None
|
Use rounded pill style |
None
|
**kwargs
|
Any
|
Additional HTML attributes (cls, id, hx-, data-, etc.) |
{}
|
Returns:
| Type | Description |
|---|---|
Span
|
FastHTML Span element with badge classes |