Web and CSS guides

Build and Test a Dismissible CSS Badge

·

Use a status badge to describe a state alongside the item it belongs to. Add a dismiss button when someone can remove the label, such as clearing a selected filter.

Badge Generator

Build a teal outlined badge with a status dot

Set Badge text to In review, CSS class name to review-badge, Size to LG, Variant to Outlined and Shape to Pill. Enter #22585D for Main color and leave Text color blank to use the same color for the caption.

Turn on Show status dot. The text starts after a seven-pixel circular dot, enclosed by a one-pixel border. In a standalone export, the background behind the outlined badge will show through.

Build a teal outlined badge with a status dot
SettingValueWhat to look for
SizeLG14 px text
VariantOutlined1 px colored edge and transparent fill
ShapePillFully rounded ends

CSS Backgrounds and Borders Level 3

Check the two distinct keyboard controls

Enable Interactive label and Add dismiss button. Choose Standalone HTML, download the file and open it in your browser. Press Tab to focus In review and Tab again to focus Remove badge. The enclosing pill contains two separate native buttons.

Press Enter or Space while Remove badge has focus. The supplied script removes the badge. Reload the file to test it again. In your project, connect the label button to the appropriate action, such as opening a list of matching records.

HTML Standard button elementMedia Queries Level 5 reduced motion

Common questions

Can the dot carry the entire status?

Include the status in the visible words. The dot uses the current caption color and serves as decoration.

Do I need a framework for the downloaded badge?

The standalone export uses HTML and CSS. Enabling dismissal adds a short script for the remove button.

Sources

Put it into practice.

Related guides