Carousel

Slide in una traccia con scroll-snap e senza dipendenze: Precedente e Successiva, punti opzionali, swipe e tasti freccia, ciclo continuo, più slide per vista e riproduzione automatica opzionale che si mette in pausa al passaggio del puntatore e al focus, secondo il pattern Carousel di WAI-ARIA.

Disponibile in
  • Angular: disponibile
  • Vue: disponibile
  • React: disponibile
  • React Native: disponibile

Utilizzo

Slide 1 of 4

Importazione

ts
import {
  SoneCarouselComponent,
  SoneCarouselContentDirective,
  SoneCarouselDotsComponent,
  SoneCarouselItemDirective,
  SoneCarouselNextComponent,
  SoneCarouselPreviousComponent,
} from "@surface-one/angular/carousel";

Riferimento API

SoneCarouselComponentComponente

`sone-carousel` — a carousel (WAI-ARIA carousel pattern; shadcn/ui and spartan/ui Carousel) with no dependency: the slides (`soneCarouselItem`) sit in a CSS scroll-snap track (`soneCarouselContent`), so swiping, the trackpad and the wheel are the browser's own. `soneCarouselPrevious` / `soneCarouselNext` and `sone-carousel-dots` step it, ArrowLeft / ArrowRight (ArrowUp / ArrowDown when `vertical`) step it while focus is inside, and `[(index)]` is the current slide. `loop` wraps at the ends. It is a `region` with `aria-roledescription="carousel"` (name it with `aria-label`), each slide a `group` named "N of M". Nothing moves on its own unless `autoplay` (ms) is set: then it advances, holds while the pointer rests on it or focus is inside, starts stopped under reduced motion, and shows a rotation control to stop and restart it.

Selettore
sone-carousel
Esporta come
soneCarousel
Input
NomeTipo Predefinito
indexbidirezionale

The current slide, two-way: `[(index)]`.

number0
orientationCarouselOrientation"horizontal"
loop

Wrap from the last slide to the first and back.

booleanfalse
autoplay

ms between automatic steps; 0 (the default) never moves on its own.

number0
roleDescription—$localize`:Role description of a carousel region:carousel`
slideRoleDescription—$localize`:Role description of one slide of a carousel:slide`
stopLabel—$localize`:Stops a carousel's automatic rotation:Stop automatic slide show`
startLabel—$localize`:Starts a carousel's automatic rotation:Start automatic slide show`

SoneCarouselContentDirectiveDirettiva

`[soneCarouselContent]` — the scroll-snap track of the slides. It is focusable (the arrow keys step the carousel from it) and a polite live region while nothing rotates.

Selettore
[soneCarouselContent]

SoneCarouselDotsComponentComponente

`sone-carousel-dots` — one button per slide; the current one is `aria-current`.

Selettore
sone-carousel-dots
Input
NomeTipo Predefinito
label

The group's name, when no static `aria-label` gives one.

—$localize`:The group of a carousel's slide buttons:Choose slide`

SoneCarouselItemDirectiveDirettiva

`[soneCarouselItem]` — one slide: a `group` with `aria-roledescription="slide"`, named "N of M".

Selettore
[soneCarouselItem]
Input
NomeTipo Predefinito
label

The slide's name (default: a static `aria-label`, else its position, "2 of 5").

string | nullnull

SoneCarouselNextComponentComponente

`button[soneCarouselNext]` — steps on one slide; disabled on the last unless `loop`.

Selettore
button[soneCarouselNext]
Input
NomeTipo Predefinito
variantButtonVariant"outline"
sizeButtonSize"icon-sm"
label

The button's name, when no static `aria-label` gives one.

—$localize`:Shows the next carousel slide:Next slide`

SoneCarouselPreviousComponentComponente

`button[soneCarouselPrevious]` — steps back one slide; disabled on the first unless `loop`.

Selettore
button[soneCarouselPrevious]
Input
NomeTipo Predefinito
variantButtonVariant"outline"
sizeButtonSize"icon-sm"
label

The button's name, when no static `aria-label` gives one.

—$localize`:Shows the previous carousel slide:Previous slide`