Skip to content
Badged content
Badged content
Badged content
Badged content Badged content Badged content Badged content Badged content Badged content Badged content Badged content
Badged content Badged content Badged content Badged content
Badge - Web Component
The Badge component can be used imported from:
Playground
Parameters
The Web component uses the <z-badge>
tag:
By default, all the parameters are optional or can be set in different, except for the ones marked as required
The parametrization of the component can be done with the following custom HTML params:
Name | Type | Description | Slot | A11y |
---|---|---|---|---|
config | string | The main parameter has three components following the pattern:
| ||
text if config is "text" | string | Value inside the badge. Needs to be used if the type of the badge is | ||
icon if config is "icon" | string | Sets icon of the badge. Needs to be used if the type of the badge is This icon needs to be always the | ||
content | string | The content of the badge. | default | |
fill | string | Changes the color of the badge. Check the colors section. |
Important!
In the examples of the following explanations we are applying a style to the content of the badge to better visualizing the positioning of the badge in relation to the content.
Slots
This component has slots. Check the documentation about how to use the slots.
Name | Tags | Description |
---|---|---|
default | span | Content of the badge. |
Parameters use
content
The thing to be assigned to the badge. It uses the default
slot too.
config
type
For the z-badge
component, the type
parameter establishes the type of content that the badge is going to be showing. The possibles variants are: dot
, icon
, text
.
- The
z-badge
component will use thedot
configuration as default, matching the dot variant of the specifications. This is the default value.
- The
text
variant will useconfig="text"
and will receive the text to be shown in another attribute calledtext
. If nottext
is provided, the badge will look like the dot base variant.
- The
icon
variant will useconfig="icon"
and will receive the icon to be shown in another attribute calledicon
. Make sure that you use theline
version of the icons for the Badge. Otherwise, the icon won't be shown to avoid misusage of the component.
style
The first modifier is style
, that can receive the value outline
to make the badge separate from the content by a line that matches the background. This uses the --z-bg
variable, so it's important that this is changed within the context.
size
The second modifier is size
, which can have the values xs
, s
, m
(default), or l
. Must be always at the end and the z-badge
attribute. The type
can be skipped if the value is dot
.
fill
The attribute fill
changes the color of the badge background. The value names available are defined using the color palettes (check the colors section), and the possible values are: bold
, blue-dark
, blue-sky
, moss
, peach
, lemon
, or dove
. The color of the text adapts for contrast.
Special uses
Badge for Profile
When Badge
is used with Profile
, the position is adjusted:
Notifications
We can use the Icon
to make a notifications alert:
Browser support
Detected engine:
Chromium
Webkit
Gecko