# Carousel

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

[All components](https://rickylabs.github.io/netscript/design-system/components/) · [Theme builder](https://rickylabs.github.io/netscript/create/) · [Implementation source](https://github.com/rickylabs/netscript/blob/main/packages/fresh-ui/registry/components/ui/carousel.tsx)

## Live preview

[Open live carousel preview](https://rickylabs.github.io/netscript/assets/fresh-ui/preview/?component=carousel&theme=studio-utility)

## Install

```bash
netscript ui:add carousel
```

## Usage and examples

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

```tsx
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.

| Owner | Prop | Type | Optional | Description |
| --- | --- | --- | --- | --- |
| `CarouselProps` | `label` | `string` | No |  |
| `CarouselProps` | `slides` | `[object Object]` | No |  |
| `CarouselProps` | `orientation` | `"horizontal" \| "vertical"` | Yes |  |
| `CarouselProps` | `controls` | `"outside" \| "inside"` | Yes |  |
| `CarouselProps` | `dots` | `boolean` | Yes |  |
| `CarouselProps` | `counter` | `boolean` | Yes |  |
| `CarouselProps` | `defaultIndex` | `number` | Yes |  |
| `CarouselProps` | `onIndexChange` | `(index: number) => void` | Yes |  |
| `CarouselProps` | `class` | `string` | Yes |  |

## Keyboard

| Key | Action |
| --- | --- |
| `Tab` | Focus previous/next controls |
| `Enter/Space` | Activate 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](https://www.w3.org/WAI/ARIA/apg/patterns/carousel/)

- 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.
