Skip to main content

Badge

Badges can be used to highlight new or unread items, Limited usage is recommended, mainly for displaying numeric values in combination with other data to provide context. Do not use in place of labels, or any other similar element.

123

Basic usage

{{
html.badge({
'label': '123'
})
}}

Accessibility

Badges strongly rely on the context in which they’re presented to properly communicate what the badge means. You should not rely on colour alone to indicate what a badge means.

Ideally, treat badges as a secondary piece of information, which is visually associated with an obvious text label, or a screenreader friendly label.

{{
html.button({
'label': 'Notifications ' ~
html.badge({
'label': '7'
})
})
}}

Screenreader friendly labels

Badges may be confusing to users of screen readers and other assistive technologies where they may not be able to rely on visual cues or positioning to judge the context of the numbers.

Unless an associated text label is close enough to make it clear what the badge is counting, such as ‘Notifications (8)’, consider adding additional information with a visually hidden label.

{{
html.badge({
'label': '7 <span class="hide">unread items</span>',
'class': 'badge--danger'
})
}}