Skip to the page
TACTILE UI

Kit part · Carousels

Carousel

Slides seen one at a time through a viewer’s gate: transport keys either side of a frame counter on an LCD, lamp keys to jump, swipe on touch. Nothing moves on its own unless you ask it to.

Element
<tui-carousel>
Needs
kit.css + kit.mjs
Rules
carousel.rules.md · 5
Finishes
Aluminium · Graphite · Porcelain · Black
Volumes
Tactile · Quiet
On this page
  1. Variants
  2. Every state, at once
  3. API
  4. Markup
  5. Accessibility
  6. How it’s built
  7. Rules
  8. Related parts
01

Variants

Captions under pictures
Quotes · stop key first
02

Every state, at once

Both finishes, side by side. Hover, pressed and focus are forced with .is-hover, .is-down and .is-focus; checked and disabled are real.

Aluminium

PartRestHoverPressedFocusDisabled
Transport
Lamp key
Counter01/0402/0403/0404/0401/04

Graphite

PartRestHoverPressedFocusDisabled
Transport
Lamp key
Counter01/0402/0403/0404/0401/04
03

API

NameKindValuesWhat it does
labelattributerequiredNames the carousel: role="region" with aria-roledescription="carousel".
.tui-carousel__slideclasson each childA slide. Give each an aria-label (or a figcaption); it becomes “2 of 4: Next session”.
.tui-carousel__picture · __captionclass—A picture area and a printed caption strip: title in <b>, a line in <span>.
autoplayattributems, e.g. 6000Advance on a timer. Adds a stop key first in the bar; hover or focus holds it; reduced motion never starts it.
indexattribute · property0-basedThe slide in the gate. Setting the property scrolls there.
go(i)methodwraps at the endsBring slide i into the gate.
changeeventbubblesA different slide is in the gate.
.tui-carousel__countclassLCD, “02/04”The frame counter. Hidden from screen readers: the slide’s own label says the same.
.tui-carousel__picksclasslamp keysOne 24px key per slide, the current lamp lit amber. Hidden under 300px.
ArrowLeft · ArrowRightkeyboardon the gatePrevious and next slide. Home and End: the first and last.
Swipetouchnative scrollScroll snapping, one slide per swipe (scroll-snap-stop).
04

Markup

<tui-carousel label="Studio tour">
  <figure class="tui-carousel__slide" aria-label="Solar today">
    <div class="tui-carousel__picture">…</div>
    <figcaption class="tui-carousel__caption"><b>Solar today</b><span>Peaked at 5.4 kW at 13:00.</span></figcaption>
  </figure>
  <figure class="tui-carousel__slide" aria-label="Next session">…</figure>
  <figure class="tui-carousel__slide" aria-label="Levels">…</figure>
</tui-carousel>

<!-- Rotation only when asked: a stop key comes first, reduced motion keeps it still. -->
<tui-carousel label="Quotes" autoplay="6000">…</tui-carousel>
import '/kit/kit.mjs';   // defines <tui-carousel>

const tour = document.querySelector('tui-carousel');
tour.addEventListener('change', () => track('slide', tour.index));
tour.go(2);   // bring the third slide into the gate

Needs kit.css and kit.mjs. How to install the kit.

05

Accessibility

  • The WAI-ARIA carousel pattern: a named region with aria-roledescription="carousel"; each slide a group with aria-roledescription="slide" and a label like “2 of 4: Next session”.
  • Slides out of the gate are inert, so Tab never lands on something you cannot see.
  • The gate is a polite live region while nothing rotates, so a change of slide is read out; during rotation it is silent, and focus or hover holds it.
  • Keys have names (“Next slide”, “Slide 3: Levels”); the lit lamp is also aria-current.
  • Rotation never starts under prefers-reduced-motion, and the stop key is the first control, as the pattern asks.
06

How it’s built

A custom element that moves its slides into a track and builds the gate and the bar around them. The track is a native horizontal scroller with scroll-snap-type: x mandatory and scroll-snap-stop: always, so a swipe, a trackpad and scrollTo all land on whole slides with no gesture code; the counter follows the scroll position as a slide passes halfway, and scrollend settles which slides are inert. Under reduced motion the keys jump instead of gliding. The gate is the kit’s recess, 6px deep, with an inner shadow where its upper wall shades each slide.

07

Rules

carousel.rules.mdIn the brain

A carousel hides most of what it holds, so nothing important may live only there, and it never moves unless asked.

5 rules in this file, with the foundations they rest on and the anti-patterns that break them. Full rules ship in the brain with the Pass.

08
02:52min

LCD

A value that changes, on grey-green liquid crystal, with a ghost of the unlit segments behind it: clocks, battery, counters.

Lamp

The only colour in the kit: a lamp that is on. Green is on, amber is waiting, red is recording or failing, blue is linked, white is standing by. Always next to words.

Icon key

A key with an icon and no words, square or round: transport, power, the small tools. Its aria-label names it; a tip shows the name.

Docs
Finish
Volume