Skip to content

Switch

Switch is part of the Forms and selection group. On/off setting control for preferences that apply immediately.

Terminal window
npx bambiui add switch --framework react
Terminal window
npx bambiui add switch --framework solid
Terminal window
npx bambiui add switch --framework svelte
Terminal window
npx bambiui add switch --framework vue
import { Switch, SwitchThumb, SwitchLabel } from "@/components/ui/switch";
export function Example() {
return <Switch />;
}
import { Switch, SwitchThumb, SwitchLabel } from "~/components/ui/switch";
export function Example() {
return <Switch />;
}
<script lang="ts">
import { Switch, SwitchThumb, SwitchLabel } from "$lib/components/ui/switch";
</script>
<Switch />
<script setup lang="ts">
import { Switch, SwitchThumb, SwitchLabel } from "@/components/ui/switch";
</script>
<template>
<Switch />
</template>
Switch preview should be verified in the target framework after copying the component source. Interactive behavior comes from generated public artifacts, not docs-only mock behavior.

Use for persistent settings such as notifications, theme options, and feature toggles.

Generated output uses serializable data-* attributes for state and styling. Controlled components fire bambi:<event-name> events and expect application state to update externally; uncontrolled components manage local source state and still fire events.

Use semantic labels, visible focus states, and keyboard interaction patterns appropriate for Switch. Do not hide required instructions in transient UI. Verify focus movement and disabled states in the installed framework output.

Switch, SwitchThumb, SwitchLabel

Customize tokens after installing and previewing the component. Relevant tokens include:

  • --bambi-intent-primary-bg
  • --bambi-muted
  • --bambi-radius-lg