Skip to content

Carousel

@astryxdesign/core v0.7.1 · Carousel

Props ​

NameTypeDefaultDescription
gap0 | 0.5 | 1 | 1.5 | 2 | 3 | 41Space between items, as a spacing step.
hasButtonsbooleantruePrevious and next buttons when the row overflows.
hasEdgeFadebooleantrueFade the edges that still hide overflow.
hasLoopbooleanfalseWrap from the last item to the first. Buttons stay available at both ends while the row overflows.
hasSnapbooleanfalseSnap each direct child to the start edge.
paddingSpacingStep—Inline padding inside the scrollport, with matching scroll-padding.
labelstringCarouselAccessible name of the region. The default is localized.

Exposed ​

NameSignatureDescription
scrollNext() => voidScroll forward by about one viewport. With hasLoop, wraps to the start at the end.
scrollPrev() => voidScroll backward by about one viewport. With hasLoop, wraps to the end at the start.
scrollTo(index: number) => voidScroll the 0-based item to the start edge. The index is clamped. Only the carousel scrolls.
canScrollNext() => booleanWhether a forward scroll is available. With hasLoop, true whenever the content overflows.
canScrollPrev() => booleanWhether a backward scroll is available. With hasLoop, true whenever the content overflows.

Slots ​

  • default: carousel items. Each top-level node is one slide. Fragments are flattened, and empty text is skipped.

Theme ​

The root class is astryx-carousel. The scrollport is astryx-carousel-scroller in the theme layer through .astryx-carousel__scroller.

  • --astryx-carousel-gap: space between items. Set from gap.
  • --astryx-carousel-padding: inline padding and scroll-padding. Set from padding.