ba-icon

Use ba-icon to display an icon from our icon library

GitHub Storybook

Shapes and symbols can mean different things to different people. Commonly recognisable icons are rare and the same icon can have a different meaning depending on the app or website used. Adding text next to the icons can remove the ambiguity and clarify the meaning

Further Reading:

As our approach is to always supply supportive text when using icons, the icons can be considered to be decorative and the nested SVGs can be hidden from screen readers.

Further Reading:

Before implementing a design ensure that it meets colour contrast requirements.

Active user interface components and meaningful non text graphics should be distinguishable by people with visual impairments. The minimum contrast for such components is 3:1.

In most scenarios it's preferable to have visible text next to the icon. Alternative text can be used as a last resort when there isn't space for visible text next to the icon.

Further reading:

In high contrast mode the icons colour reverts to a combination of current text and canvas colours

Code

Properties & Attributes

Property Attribute Description Type Default
alt alt Defines the visually hidden text and the svg title string | undefined undefined
name (required) name Name of the icon to be shown string undefined
size size Size of the icon string | undefined '32'

A page with all the icons can be found here Iconography.

Slots

Slot Description Permitted elements
Unnamed slot Elements will render in the body of the component None

Permitted ARIA roles

None

Parent components

ba-icon can be slotted into:

Usage

Basic Usage

Most scenarios will only require the name and a size

Showing the add icon at 24px (1.5 rem) by 24px (1.5 rem)
<ba-icon name="add" size="24"></ba-icon>

Adding alternative text

If there isn't space to put the text next to the icon - the alt attribute can set some visually hidden text for assistive technology to read to the user

An icon that is used as part of a button with some descriptive text to help assistive technology users understand what happens when the button is clicked
<button>
  <ba-icon name="close" alt="Close modal"></ba-icon>
</button>
GitHub Storybook Figma library Version 3 release guide Release history BAgel helper QA process