Badges
Badges are a way of making elements in the interface stand out to users. They should be used sparingly to call attention to important status, labels and other indicators warranting attention.
User Notifications
One of the most common badge types is the User Notification Badge, which appears alongside an avatar or icon and serves as a visual cue for items needing the user’s attention. The badge itself may display a count of items or an exclamation point indicating that user action is required.
When to Use
- To draw attention to information needing the user’s attention when the information, status or count changes based on user action.
When Not to Use
- Do not use to highlight information that does not change based on user action.
Behavior
On this badge example, display “99+” to indicate that the number is greater than 99.
Examples
- User Notification Badges (above)
- Tally Badges
- Informational Badges
Usage
When to Use a Badge
Badges are best used to communicate a status or count associated with an interface element or data on the screen that changes based on conditions and/or user activity. Information that can be communicated in 1-2 words, a numerical count, or an icon are a good fit for badges; messages that require lengthier text are not.
See Intro to Messages for a comparison of when to use each message type.
Indicating Status within a Badge
Each of the badge examples may use a color corresponding to its status type.
Status Types
- Critical (Red)
- Warning (Warning Yellow)
- Positive (Green)
- Neutral (Slate)
Examples
Tally Badges
Tally badges are used to indicate a count of something that changes based on status or user actions.
When to Use
- To indicate a count of items when the count changes.
- Can be used in conjunction with icons or text.
When Not to Use
- The count being communicated doesn’t change.
Count-Only Badge
This badge is recommended for counts when a lower level of visual prominence is warranted and when it will be clear that the count corresponds to the neighboring text. This badge may appear next to text or a link.
Table Title
Flight No. | Departure Time | Arrival Time | Availability |
---|---|---|---|
DL0431 |
6Seats Available |
||
AA1321 |
3Seats Available |
Count with Text inside the Badge Example
This badge is recommended for counts of items when a stronger level of visual prominence is warranted and when the count and the label are best perceived as a single element.
Table Title
Flight No. | Departure Time | Arrival Time | Availability |
---|---|---|---|
DL0431 | 5 Seats Available | ||
AA1321 | 8 Seats Available |
Count with Icon Example
This badge may be used in conjunction with icons when the number of items related to the icon will change based on status or user actions. Click on the image below to view a coded example.
Informational Badges
Informational badges are used to indicate the presence or availability of something or to highlight a key piece of data warranting strong visual prominence (for example, a value in a KPI bar or a status of a flight). Status colors may be used to associate a status with the value, following the Color Usage Guidelines.
When to Use
- To give visual prominence to a data element that requires extra visual prominence.
- To assign status connotations to a key data element (positive, warning, critical or neutral).
When Not to Use
- Do not use in form validation contexts. Instead, use validation messaging.
Text and Numerical Values
Use to give visual prominence to data that changes, such as status indicators or key progress indicators. This badge may display popovers or tooltips for additional information.
Table Title
Flight No. | Departure Time | Arrival Time | Status |
---|---|---|---|
DL0431 | Delayed | ||
AA1321 | On-Time |
Icon Informational Badges
Use to give visual prominence to an icon representing the presence or status of something that changes. A link or label may appear next to this badge. To view the badge in the example below, click on the Avatar to reveal the Popover that holds the badge.
Developer Notes
Standard Badge with Status
The standard badge is created using the spark-badge
class and coupling this with an additional class that determines the status of the badge. The available status classes are spark-badge--neutral
, spark-badge--warning
, spark-badge--critical
, and spark-badge--success
.
By default, the standard badge is displayed at a large size, but a smaller badge is available using the spark-badge--sm
class.
Note that the examples above utilize CSS helper classes to assist with spacing and are not necessary for use with badges.
User Notification Badges
User notification badges are created using the spark-badge--notification
class and an associated color class. The available color classes are spark-badge--notification__neutral
, spark-badge--notification__critical
, spark-badge--notification__warning
and spark-badge--notification__success
. An additional class of spark-badge--notification__light
is also available for use as a neutral variation when the notification badge is used with a Text Avatar in the Header.
Avatar
User notification badges applied to Avatars should be placed inside the spark-avatar
element container. This is to allow the correct positioning of the badge.
Icon Notifications
User notification badges can also be applied to the Icon Buttons. Once again, the spark-badge--notification
element should be placed inside the button
element. A class of spark-badge--icon
is also required on the button
element to allow for the correct positioning of the badge.
Tally Badges
Tally Badges are similar to Standard badges but will have a numerical count as part of the badge label.
Note that the examples above utilize CSS helper classes to assist with spacing and are not necessary for use with badges.
Informational Badges
Informational badges are created in a similar manner to Tally and Standard badges and can be combined with Tooltips or Popovers.
This particular item is
extremely overpriced.
This particular item is
extremely overpriced.
Accessibility Notes
User Notification Badges
When applying a User Notification Badge to text or image Avatars, more descriptive text should be provided to screen-readers and assistive devices to make the context of the badge clearer, and to create the association between the badge and the avatar.
In the case of the text avatar, an aria-label
attribute is required on the avatar to provide the full length name of the user or a description of what the abbreviations stand for. An aria-describedby
attribute is also added to indicate which element, in this case the badge, provides additional details. The badge itself also contains an aria-label
attribute to describe in detail the meaning behind the numerical count.
In the case of the image avatar, ensure that an alt
attribute is provided for the image used. As with the text avatar, an aria-describedby
attribute is set on the image and an aria-label
provided for the badge element.
The principles above apply to notifications used with Icon Buttons as well as Links.
Tally Badges
When using Tally Badges with icons, it might be necessary to provide a text alternative to the icon via an aria-label
attribute or to hide the icon from assistive technologies using an aria-hidden
attribute if the text within the badge is sufficient.
Informational Badges
Informational badges with icons will follow the same Accessibility principles as Tally badges above.
For guidelines on how to make Badges with Tooltips or Popovers accessible, refer to the Accessibility tab under Tooltips and the Accessibility tab under Popovers.