Skip to main content
NetScriptdocs Search docs ⌘K v0.0.9
Browse documentation

Carousel

Manual native scroll-snap carousel with stable-focus boundary controls.

All components · Theme builder · Implementation source

Live preview

Open live carousel preview

Install

Shell
netscript ui:add carousel

Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

TypeScript
import { useState } from 'preact/hooks';
import { Carousel } from '@app/components/ui/carousel.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><Carousel label="Order attachments" slides={[{label:"Invoice",content:<p>Invoice</p>},{label:"Packing slip",content:<p>Packing slip</p>}]} /></div><p role="status">{notice}</p></>);
}

Props

Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

OwnerPropTypeOptionalDescription
CarouselPropslabelstringNo
CarouselPropsslides[object Object]No
CarouselPropsorientation"horizontal" | "vertical"Yes
CarouselPropscontrols"outside" | "inside"Yes
CarouselPropsdotsbooleanYes
CarouselPropscounterbooleanYes
CarouselPropsdefaultIndexnumberYes
CarouselPropsonIndexChange(index: number) => voidYes
CarouselPropsclassstringYes

Keyboard

KeyAction
TabFocus previous/next controls
Enter/SpaceActivate control

Tokens

Semantic contract roles: border/strong, space/stack/gap, text/fg.

CSS custom properties referenced directly: --ns-border, --ns-border-strong, --ns-border-width, --ns-card, --ns-fg, --ns-font-data, --ns-muted-fg, --ns-radius-control, --ns-ring, --ns-space-1, --ns-space-2, --ns-space-3, --ns-stack-gap, --ns-text-caption.

Contract and compatibility

Accessibility pattern: WAI-ARIA guidance

  • Native overflow scrolling and mandatory snap points retain touch/trackpad behavior. ResizeObserver realigns the current slide without global listeners.
  • No autoplay. Boundary controls use guarded aria-disabled so activation never removes focus. After hydration only the current slide is interactive; before hydration native scrolling keeps all slide content available.
  • defaultIndex is clamped to available slides; changing slide count or orientation keeps a valid current index.

Design contract values marked planned are not implementation props. The props above describe what ships today.

Search all documentation

Type a term to search the documentation.