Usage
Badge
Color
Size
xs
sm
md
lg
xl
Radius
xs
sm
md
lg
xl
Gradient variant
To use gradient as Badge background:
- set
variant
togradient
- set
gradient
to{ from: 'color-from', to: 'color-to', deg: 135 }
, wherecolor-from
andcolor-to
are color fromtheme.colors
deg
is linear gradient deg
Indigo cyan
Lime green
Teal blue
Orange red
Peach
Full width and overflow
Badge will take full width of container if fullWidth
prop is true
.
If badge cannot fit in its container, overflow content will be hidden with ellipsis:
Full width badge
Badge with overflow
Right and left sections
Badge with Avatar
Badge with right section
Badge with left section
Polymorphic component
Badge is a polymorphic component, you can change root element:
Link badge
$$$ Get lots of money $$$
Badge component props
Name | Type | Description |
---|---|---|
children | ReactNode | Badge label |
color | MantineColor | Key of theme.colors |
fullWidth | boolean | Sets badge width to 100% of parent element, hides overflow text with text-overflow: ellipsis |
gradient | MantineGradient | Controls gradient, applied to gradient variant only |
leftSection | ReactNode | Section rendered on the left side of label |
radius | number | "xs" | "sm" | "md" | "lg" | "xl" | Key of theme.radius or any valid CSS value to set border-radius, "xl" by default |
rightSection | ReactNode | Section rendered on the right side of label |
size | "xs" | "sm" | "md" | "lg" | "xl" | Badge height and font size |
variant | BadgeVariant | Controls appearance |
Badge component Styles API
Name | Static selector | Description |
---|---|---|
root | .mantine-Badge-root | Root element |
inner | .mantine-Badge-inner | Badge label container, contains children |
leftSection | .mantine-Badge-leftSection | Left section, controlled by leftSectionProp |
rightSection | .mantine-Badge-rightSection | Right section, controlled by rightSectionProp |