# Switch

Toggles a setting between on and off. Use it when the change takes effect immediately rather than waiting for form submission.

Package: `@kela-systems/ui-components` 4.1.0

```tsx
import { Switch, SwitchField } from "@kela-systems/ui-components";
```

Links (Kela sign-in needed): [Storybook](https://main--6af1efd9453270bb59a6c00c.chromatic.com/?path=/docs/components-switch--docs), [Source](https://github.com/Kela-Systems/kela/tree/main/packages/next/ui-components/src/switch), [Figma](https://www.figma.com/design/anhlwrbFM6mUiL0klxeK1I/ARK---Design-System?node-id=60-438)

## Examples

### SwitchField

SwitchField adds the label and description, and makes the whole row the target.

```tsx
import { Stack, SwitchField } from "@kela-systems/ui-components";

export default function SwitchFieldExample() {
  return (
    <Stack gap={4} className="w-full max-w-sm">
      <SwitchField
        defaultChecked
        label="Auto-track"
        description="Keep the camera on the selected track."
      />
      <SwitchField label="Night mode" />
      <SwitchField
        variant="box"
        placement="end"
        label="Geofence alerts"
        description="Alert when a track crosses the north fence."
      />
    </Stack>
  );
}
```

## Props

A `className` on a part adds layout only: placement, sizing and spacing. Pick a look with a variant.

### Switch

| Variant | Values | Default |
| --- | --- | --- |
| `size` | `sm`, `default` | `default` |

Also takes the props of `@base-ui/react/switch`.

### SwitchField

| Variant | Values | Default |
| --- | --- | --- |
| `size` | `sm`, `default` | `default` |
| `variant` | `default`, `box` | `default` |
| `placement` | `start`, `end` | `start` |

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` (required) | `React.ReactNode` |  |  |
| `description` | `React.ReactNode` |  |  |

Also takes the props of `@base-ui/react/switch`.
