Switch
Switch is part of the Forms and selection group. On/off setting control for preferences that apply immediately.
Installation
Section titled “Installation”npx bambiui add switch --framework reactnpx bambiui add switch --framework solidnpx bambiui add switch --framework sveltenpx bambiui add switch --framework vueimport { 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>Preview
Section titled “Preview”Behavior
Section titled “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.
Accessibility
Section titled “Accessibility”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.
Exports
Section titled “Exports”Switch, SwitchThumb, SwitchLabelTokens
Section titled “Tokens”Customize tokens after installing and previewing the component. Relevant tokens include:
--bambi-intent-primary-bg--bambi-muted--bambi-radius-lg