Skip to content

Badge

FilterChat

Badge displays a dynamic notification that can be placed within clickable elements such as a button a link, profiles, or avatars. It enhances the component to which it is attached with additional information like counting hidden selections and communicating success, warnings or errors.

Badges are typically positioned as overlays to other components, such as buttons, links or avatars. Don't place badge as a standalone component; always wrapping another element.

UX/UI Guidelines

Check the design documentation of the component in ZeroHeight.

Implementations

The component Badge is available in the following technologies:

CSS Components
cssreactvue
Web Components
webreactvueangular

Parameters

Parameters

Parameters are the attributes that can be used to customize the component when using it in a project. They apply to the WebComponents implementation and wrappers and to the Vue and React CSS implementations. Some parameters names change between the implementations, in order to follow the conventions of each technology and framework.

For example, the param model is named ngModel in Angular, modelValue in Vue, but stays as model in React.

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 params or properties:

NameTypeSlotDescription
configstring

The main parameter has three components following the pattern: <type><?:style><?:size>.

  • type: Establishes the type of content that the badge is going to be showing. The possible values are: dot , icon, text.

    ts
    export type ZBadge_Type = 'dot' | 'text' | 'icon';
  • style: (optional) establishes the style of badge is going. The possible value is outline.

    ts
    export type ZBadge_Style = 'outline';
  • size: (optional) defines de size of the badge. The default value is m, being omitted from the param. The possible values are: xs, s, or l. Check the sizes section.

    ts
    export type ZBadge_Size = 'xs' | 's' | 'l';
text
if config is "text"
string

Value inside the badge. Needs to be used if the type of the badge is text.

icon
if config is "icon"
string

Sets icon of the badge. Needs to be used if the type of the badge is icon.

This icon needs to be always the outline styled version to avoid visual artifacts.

Check all the available icons here.

contentstringThe content of the badge.
fillstring

Changes the color of the badge.

ts
export type ZBadge_Fill =
  | 'bold'
  | 'blue-sky'
  | 'moss'
  | 'peach'
  | 'lemon'
  | 'dove';
customobject

A record of key-value pairs to set the CSS custom tokens. It's a complex attribute set as an JS object in stringified JSON format.

Example:

html
<z-badge custom='{"fill":"#06e7a3"}' />

Check the available values in the customization section.

custom-strstring

The stringified version of the custom property. It follows the pattern key:value;key:value;, with the possibility of setting multiple values and spaces between the punctuation characters.

Example:

html
<z-badge custom-str="fill:#06e7a3" />
z-themestring

Sets the theme of the component. The possible values are light and dark.

html
<z-badge z-theme="dark" />

From Figma to code

You can check the Figma implementation here. The available properties are:

  • Size (select)
  • Type (select)
  • Color (select)
  • Outline (boolean)
  • Label (text)
  • Icon (instance)

Customization

INFO

Check everything about the customization mechanics in the "How it works" documentation.

CSS VariableTypeDescription
--z-badge--bgcolorBackground color
--z-badge--colorcolorForeground color
--z-badge--border-colorcolorBorder color

The background, foreground & border color can be customized using the --z-badge--bg, --z-badge--color and --z-badge--border CSS variables or the custom attribute.

Badge content