Airframe GitHub Storybook
Component

ba-download

The ba-download component provides an intuitive way for users to download files

Airframe

Active
Figma

Web Components

Active
Storybook Github

React

Planned

React Native

Planned
Design Code Accessibility QA
A

Icon

Helps users quickly identify the purpose of the component

B

Filename

Clearly indicates the name of the file being downloaded

C

File type (optional but recommended)

Provides users with information about the file format, helping them make informed decisions about downloading

D

File size (optional but recommended)

Provides users with information about the file size, helping them make informed decisions about downloading

E

Download button

A clear and accessible button that initiates the download process when clicked or activated via keyboard, with appropriate focus indicators and accessible labeling

The filename should be descriptive and concise. It should give the user a good idea of what they are downloading.

Show the file size (e.g. 2.5MB) as it helps users understand what they are downloading. For example they may choose to not download a large file if they are on a mobile data connection.

This helps users understand if their device can support the format before they download the file.

The file name is the name of the file once it's downloaded to their device. It would be odd if the file had the word download in the filename

<ba-download filename="File Name" href="link/to/file.pdf" size="1MB"></ba-download>
Property Attribute Description Type Default
filename(required) filename The filename of the download. This will also be used for the downloaded file name. string undefined
href(required) href Link to the file / origin of the download string undefined
loading loading Show the loading state boolean | undefined false
size size Size of the file e.g 1.2MB string | undefined undefined
type type The file type e.g PDF string | undefined undefined
  • listitem (when used in a list of downloads)
Slot Description Permitted elements
Unnamed slot Elements will render in the body of the component None

ba-download can be slotted into:

Event Description Type
baClick Emitted when the internal element is clicked. CustomEvent<MouseEvent>
Method Description Type
download() => Promise<void> Triggers the download of the file. Promise<void>

Most scenarios will only require the filename, href and size attributes. Note the filename is used for the downloaded file name and the href is the link to the file

A simple download that links to a pdf file that saves to the users device as "File Name.pdf"
<ba-download filename="File Name" href="link/to/file.pdf" size="1MB"></ba-download>

Multiple downloads can be added to a page, when doing so a separator is added between each download

A group of downloads
<div role="list">
  <ba-download role="listitem" filename="File Name 1" href="link/to/file-1.pdf" size="1MB"></ba-download>
  <ba-download role="listitem" filename="File Name 2" href="link/to/file-2.pdf" size="1MB"></ba-download>
  <ba-download role="listitem" filename="File Name 3" href="link/to/file-3.pdf" size="1MB"></ba-download>
</div>

The download method can be called to trigger the download of the file. This is useful when the download needs to be triggered by a user action other than clicking the download button or to trigger the download after some other action has completed

Multiple downloads can be downloaded at the same time by clicking a download all button
<div role="list">
  <ba-download role="listitem" filename="File Name 1" href="link/to/file-1.pdf" size="1MB"></ba-download>
  <ba-download role="listitem" filename="File Name 2" href="link/to/file-2.pdf" size="1MB"></ba-download>
  <ba-download role="listitem" filename="File Name 3" href="link/to/file-3.pdf" size="1MB"></ba-download>
</div>

<ba-button>Download All</ba-button>

<script>
  const downloads = document.querySelectorAll('ba-download');
  const downloadAllButton = document.querySelector('ba-button');

  downloadAllButton.addEventListener('baClick', () => {
    downloads.forEach(el => el.download());
  });
</script>

When the loading attribute is added to ba-download the download text is replaced by a default "Preparing file" message. This is useful when the download needs to be prepared on the server before it can be downloaded

A download that is being prepared on the server
<ba-download filename="File Name" href="link/to/file.pdf" size="1MB" loading></ba-download>

The download method can be called to trigger the download of the file. This will remove loading state display text to the user to let them know the download has started

Triggering the download of a file that has finished being prepared on the server
<ba-download filename="File Name" href="link/to/file.pdf" size="1MB" loading></ba-download>

<script>
  const download = document.querySelector('ba-download');

  download.download()
</script>

Coming soon

Coming soon

This will help assistive technologies understand how many downloads there are in a group without having to tab through them all.

Disabled elements are not supported in BAgel. They are poor for accessibility and are sometimes not read properly by screen readers.

As an alternative, provide a message explaining why it’s unavailable or an alternative action that can be taken.

State: Previous element in DOM has focus

⇥ Tab

<ba-download> gets focus

State: <ba-download> has focus

⏎ Enter

Triggers download and baClick event

⇥ Tab

Next tabbable element in the DOM gets focus

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

  • Filename is descriptive and concise, giving users a clear idea of the file contents
  • Filename does not contain the word "download"
  • Multiple downloads display a separator line between each item
  • File size and type is displayed
  • Loading state is shown with clear messaging (e.g. “Preparing file”) when the file is not immediately available.
  • Download method is triggered at the appropriate time if initiated by another action (e.g. “Download All”).
  • For multiple downloads, role="list" is applied to the container and each ba-download has role="listitem"
  • ba-download has not been disabled
  • Focus indicator has not been obscured on all sides of the button

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

  • Displayed filename matches the name of the file when downloaded
  • Loading state is announced to screen readers
  • File type and size information is accessible to assistive technologies
  • ba-download is operable using assistive technology
  • Has a visible focus indicator on all sides of the button
  • Colour contrast for all states in all BAgel themes
  • Animations respect users' reduced motion settings
  • High contrast mode adjustments
Designing Developing Components BAgel helper QA process britishairways.com Careers Cookie policy