Badge
Displays a badge
1 | |
2 | <span is-="badge">Badge</span> |
3 |
Theme
Import
@import "@webtui/css/components/badge.css";
Usage
<span is-="badge">badge</span>
Examples
Variants
Use the variant-
attribute to change the color of a badge
<span is-="badge" variant-="foreground1">foreground1</span>
<span is-="badge" variant-="background2">background2</span>
1 | |
2 | <span is-="badge" variant-="background0">background0</span> |
3 | <span is-="badge" variant-="background1">background1</span> |
4 | <span is-="badge" variant-="background2">background2</span> |
5 | <span is-="badge" variant-="background3">background3</span> |
6 | <span is-="badge" variant-="foreground0">foreground0</span> |
7 | <span is-="badge" variant-="foreground1">foreground1</span> |
8 | <span is-="badge" variant-="foreground2">foreground2</span> |
9 |
Theme
Available variants match the base theme colors
Caps
Use the cap-
attribute to customize badges’ end cap styles
<span is-="badge">square</span>
<span is-="badge" cap-="round">round</span>
<span is-="badge" cap-="triangle">triangle</span>
1 | |
2 | <span is-="badge" cap-="square">square</span> |
3 | <span is-="badge" cap-="round">round</span> |
4 | <span is-="badge" cap-="triangle">triangle</span> |
5 | <span is-="badge" cap-="ribbon">ribbon</span> |
6 | <span is-="badge" cap-="slant-top">slant-top</span> |
7 | <span is-="badge" cap-="slant-bottom">slant-bottom</span> |
8 |
Theme
Pass two values separated by a space to customize the start and end cap styles
1 | |
2 | <span is-="badge" cap-="square round">square round</span> |
3 | <span is-="badge" cap-="round ribbon">round ribbon</span> |
4 | <span is-="badge" cap-="ribbon triangle">ribbon triangle</span> |
5 | <span is-="badge" cap-="triangle slant-top">triangle slant-top</span> |
6 | <span is-="badge" cap-="slant-top slant-bottom">slant-top slant-bottom</span> |
7 | <span is-="badge" cap-="slant-bottom square">slant-bottom square</span> |
8 |
Theme
Reference
Properties
Use the following custom CSS properties to style badges
--badge-color
: The color of the badge--badge-text
: The text color of the badge
#my-custom-badge {
--badge-color: #ffffff;
--badge-text: #000000;
}
Using background-color
directly will color behind the badge instead of coloring the badge shape
1 | <span is-="badge" cap-="slant-top">badge</span> |
1 | span[is-="badge"] { |
2 | --badge-color: var(--foreground0); |
3 | --badge-text: var(--background0); |
4 | background-color: grey; |
5 | } |
Theme
Extending
To extend the Badge stylesheet, define a CSS rule on the components
layer
@layer components {
[is-~="badge"] {
&[variant-="red"] {
--badge-color: red;
--badge-text: white;
}
/* ... */
}
}
Scope
- All elements with the
is-~="badge"
selector
[is-~="badge"] { /* ... */ }