Airframe GitHub Storybook

ba-carousel

Provides a horizontally scrollable content component that allows users to browse through a set of items one at a time.

GitHub

Storybook

Example heading 1

Example content

Action

Example heading 2

Example content

Action

Example heading 3

Example content

Action

Example heading 4

Example content

Action

Example heading 5

Example content

Action
<ba-carousel>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 1</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 2</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 3</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 4</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 5</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
</ba-carousel>

The carousel component should only be used when needing to show 3 or more items that benefit from horizontal scrolling instead of vertical.

If you only need to show 2 items use a standard layout patterns instead: stacked on mobile, side by side on desktop.

For 1 item, display as a standard content block with no navigation.

There is no limit to how many items can be shown on desktop as long as each item is no smaller than 264px. The default amount is 2 items.

Due to the carousel items being accessible via the keyboard, the controls to move forward and backward in the carousel have been removed from the tab flow. This makes the behaviour less confusing for screen reader users as it stops duplication.

This enables screen reader users to know how many items are in the carousel, and gives a running count of which item they are on when moving through the carousel.

Property Attribute Description Type Default
desktopSlides desktop-slides The amount of slides to show on desktop. Defaults to 2 number | undefined 2
Slot Description Permitted elements
Unnamed slot Elements will render in the body of the component <ba‑card>, <ba‑card‑promo>

ba-carousel can be slotted into:

None

A carousel with cards for the items
<ba-carousel>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 1</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 2</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 3</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 4</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 5</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
</ba-carousel>

Setting the number of visible items on desktop

The number of items can be set on desktop using the desktop-slides prop

A carousel with the number of desktop items set
<ba-carousel desktop-slides="3">
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 1</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 2</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
  <ba-card tag-text="tag text">
    <ba-image
      alt="Description of image"
      src="ba-card-live-demo.jpg"
      slot="media"
      aspect-ratio="16-9"
    ></ba-image>
    <ba-content>
      <h4>Example heading 3</h4>
      <p>Example content</p>
    </ba-content>
    <ba-link href="/link" slot="action">Action</ba-link>
  </ba-card>
</ba-carousel>
Figma GitHub Storybook Version 3 release guide Release history BAgel helper QA process