# Switch

CSS-first native switch seam for binary dashboard settings.

[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/switch.tsx)

## Live preview

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

## Install

```bash
netscript ui:add switch
```

## 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 { Switch } from '@app/components/ui/switch.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><Switch description="Priority orders appear first">Mark as priority</Switch></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 |
| --- | --- | --- | --- | --- |
| `SwitchProps` | `children` | `ComponentChildren` | No |  |
| `SwitchProps` | `class` | `string` | Yes |  |
| `SwitchProps` | `description` | `ComponentChildren` | Yes |  |
| `SwitchProps` | `error` | `boolean` | Yes |  |

```typescript
SwitchProps extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "type" | "class" | "children">
```

## Keyboard

| Key | Action |
| --- | --- |
| `Space` | Toggle checked |

## Tokens

Semantic contract roles: `border/control`, `border/input`, `primary/default`, `surface/card`, `surface/muted`.

CSS custom properties referenced directly: `--ns-border-control`, `--ns-border-hover`, `--ns-border-width`, `--ns-card`, `--ns-destructive`, `--ns-ease-normal`, `--ns-gray-1`, `--ns-gray-12`, `--ns-input-border`, `--ns-muted`, `--ns-primary`, `--ns-radius-full`, `--ns-shadow-xs`, `--ns-size-switch-height`, `--ns-size-switch-thumb`, `--ns-size-switch-width`, `--ns-switch-thumb`.

## Contract and compatibility

Accessibility pattern: [WAI-ARIA guidance](https://www.w3.org/WAI/ARIA/apg/patterns/switch/)

- Native DOM attributes pass through where the implementation accepts them.

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