Skip to content

Carousel

Preview Available in release assets

Present a finite set of media in a natively scrollable reel.

Show code
<section class="thin-carousel" aria-labelledby="carousel-title">
  <h2 id="carousel-title">Featured stories</h2>
  <div class="thin-reel" id="featured-reel">
    <figure data-media-item>
      <a href="one-large.jpg">
        <img src="one.jpg" alt="Coast at sunrise">
      </a>
      <figcaption>Coast at sunrise</figcaption>
    </figure>
    <figure data-media-item>
      <a href="two-large.jpg">
        <img src="two.jpg" alt="Pine forest">
      </a>
      <figcaption>Pine forest</figcaption>
    </figure>
  </div>
  <div data-media-controls>
    <button class="thin-button" data-variant="secondary" type="button" data-media-previous>
      <svg class="thin-icon" data-icon="chevron-left" viewBox="0 0 24 24" aria-hidden="true">
        <path d="m15 18-6-6 6-6" />
      </svg>
      <span>Previous</span>
    </button>
    <button class="thin-button" data-variant="secondary" type="button" data-media-next>
      <span>Next</span>
      <svg class="thin-icon" data-icon="chevron-right" viewBox="0 0 24 24" aria-hidden="true">
        <path d="m9 18 6-6-6-6" />
      </svg>
    </button>
    <output data-media-status>Image 1 of 2</output>
  </div>
</section>

Each authored example uses the production assets and includes copyable markup.

Anatomy

  • Named region
  • Reel
  • Linked figures
  • Optional controls and status

Variants and sizes

  • Editorial — shown above
  • Contained — shown above

Rendered fixtures exercise authored content and constrained layouts with the same production assets.

  • First — shown above
  • Middle — shown above
  • Last — shown above
  • Image failure — shown above
  • Long gallery — shown above

Interaction and keyboard behavior

Touch and trackpad scrolling work natively; optional buttons and arrow keys update only the mechanical media index.

Accessibility

Name the region, provide useful alternatives, and keep every full image reachable by link.

Contract
CAROUSEL · APG pattern
Basis
APG Carousel with native links and labelled controls
Behavior guarantees
  • Selects media and announces a bounded position; it never owns product variants, inventory, pricing, or image truth.
Evidence
  • tests/unit/library/media.test.ts
  • tests/unit/library/advanced-component-contracts.test.ts

API

Use .thin-carousel with a .thin-reel descendant and data-media-item figures.

Behavior tier: dependency-free

Structured host, property, and example tables are not authored for this item yet. Use the summary above and the primary example.

Fallback

Every image remains an ordinary link or a natively scrollable figure without enhancement.

Assets and dependencies

  • /foundation.css
  • /layouts.css
  • /components.css
  • /behaviors.js

Dependencies: None

Source: packages/ui/src/items/media/style.ts

Composition

Derived from the examples and style specs, not authored.

Composes

Used by