Airframe GitHub Storybook
Component

ba-star-rating

A component for presenting a star rating out of 5

Airframe

Active
Figma

Web Components

Active
Storybook GitHub

React

Planned

React Native

Beta
GitHub
Design Code Accessibility QA
A

Star icons

A row of five star icons that fill, half-fill, or remain empty to visually represent the rating out of 5. The icons are decorative and hidden from assistive technology

B

Rating text

The supportive text showing the numeric rating out of 5 (e.g. "2.5/5"), which conveys the rating to assistive technology

ba-star-rating is a presentational component for displaying a rating out of 5. Pass the value through the rating attribute. It is not an interactive control, so do not use it to capture or collect a rating from the user.

Use the size attribute to set the star size to either 12 or 16. Pick the size that aligns with the scale and density of the content around the rating so the stars sit comfortably alongside nearby text.

The rating value should be one of the supported half-star increments: 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5 or 5. Values outside this range or between increments will not render as intended.

<ba-star-rating rating="2.5"></ba-star-rating>
Property Attribute Description Type Default
rating(required) rating Value out of 5 to display string undefined
size size Size of the stars in the star rating "12" | "16" | undefined '12'
  • None

No slotted content available for this component.

ba-star-rating can be slotted into:

The star rating component is used to display a rating out of 5. The rating is passed as a string to the rating attribute.

Showing a rating of 3 out of 5
<ba-star-rating rating="3"></ba-star-rating>

Ratings support half-star increments, so values such as 2.5 render a half-filled star.

Showing a rating of 2.5 out of 5
<ba-star-rating rating="2.5"></ba-star-rating>

Use the size attribute to set the star size to either 12 or 16 to suit the surrounding content.

A rating displayed with larger 16px stars
<ba-star-rating rating="4" size="16"></ba-star-rating>

React documentation coming soon.

React Native documentation coming soon.

The ba-star-rating element does not contain any elements that assistive technology would recognise as clickable. It is purely presentational and should be treated as such.

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. The rating is conveyed to assistive technology through the supportive text (for example, "2.5/5").

Further reading:

No keyboard interactions have been defined for this component.

Use this checklist to confirm the component has been configured and used correctly.

  • ba-star-rating is only used to present a rating out of 5 and not as an interactive control for capturing a rating
  • The rating value is one of the supported increments (0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5)
  • The size attribute is set to either 12 or 16 to match the surrounding content
  • ba-star-rating has discernible, supportive text that communicates the rating out of 5
  • Click or interaction events are not added to ba-star-rating as it is presentational only

These checks are handled by the component and do not need to be repeated each time it is used.

  • Star icons are decorative and hidden from screen readers, with the rating text always present
  • Rating is accessible to assistive technologies through the supportive text
  • Colour contrast for the rating text and stars in all BAgel themes
  • High contrast mode adjustments
Designing Developing Components BAgel helper Web QA React Native QA britishairways.com Careers Cookie policy