Use badges for providing quick, contextual information to your users, such as notification counts, status or activity indicators, labels, priority levels, or even turn them into interactive chips using their onClick prop.
Preview
Primary Secondary Flat Outline Info Success Warning Alert
Badge Styles
The appearance of badges can be modified with two props, small and rounded:
Small badges
Primary Secondary Outline Info Success Warning Alert
Small & rounded
Primary Secondary Outline Info Success Warning Alert
Hover Effects
You can set hover to true or add the onClick prop in Svelte or React to add hover effects to your badges. This is useful for interactive badges.
Primary Secondary Flat Outline Info Success Warning Alert
Badges with Icons
You can also pass the Icon component or your own icons to the Badge component to render them with icons:
Github
Info
Success
Warning
Alert
Icon colors will always use the color of the text of the badge.
Interactive Badges
To make badges interactive, you can use the onClick prop for Svelte/React. For Astro, use the className prop to assign a custom class name to the element that you can target with document.querySelector, and add a click event listener using the native addEventListener method:
Using event listeners, we can make badges removable similar to a Chip component:
API
Prop
Default
Purpose
theme
-
Sets the theme of the badge.
hover
false
Adds hover effects if the badge needs to be interactive. Use only for Astro components.
small
false
Sets the badge to a smaller size.
rounded
false
Sets the borders of the badge to rounded.
className
-
Pass additional CSS classes for the badge.
Svelte & React Prop
Purpose
onClick
Attach on-click event listeners. If set, hover is treated as true.