switch
bejamas-ui/switchFreeComponent
bejamas/ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by bejamas/ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.bejamas.com/r/switch.jsonSource
1---2// Generated from bejamas-juno style registry. Do not edit packages/ui/src/components/switch/Switch.astro directly.3/**4 * @component Switch5 * @title Switch6 * @description A toggle control for switching between checked and unchecked states.7 * @figmaUrl https://www.figma.com/design/koxai7zw5vIuBzuVxe5T2l/bejamas-ui?node-id=2509-4236&t=YFStJ3V8fXEO8QD8-48 *9 * @status stable10 * @since 0.1.011 *12 * @preview13 *14 * <div class="flex items-center gap-3">15 * <Switch id="notifications" />16 * <Label for="notifications">Enable notifications</Label>17 * </div>18 *19 * @usage20 *21 * ```astro nocollapse22 * ---23 * import { Switch } from '@bejamas/ui/components/switch';24 * import { Label } from '@bejamas/ui/components/label';25 * ---26 *27 * <div class="flex items-center gap-3">28 * <Switch id="notifications" />29 * <Label for="notifications">Enable notifications</Label>30 * </div>31 * ```32 */3334import type { HTMLAttributes } from "astro/types";35import { cn } from "@/lib/utils";3637interface Props extends HTMLAttributes<"span"> {38 class?: string;39 id?: string;40 size?: "sm" | "default";41 checked?: boolean;42 defaultChecked?: boolean;43 name?: string;44 value?: string;45 uncheckedValue?: string;46 disabled?: boolean;47 readOnly?: boolean;48 required?: boolean;49 "aria-invalid"?: boolean | "true" | "false";50}5152const {53 class: className = "",54 id = "",55 size = "default",56 checked,57 defaultChecked,58 name,59 value,60 uncheckedValue,61 disabled = false,62 readOnly = false,63 required = false,64 "aria-invalid": ariaInvalid,65 ...rest66} = Astro.props as Props;6768const initialChecked = checked ?? defaultChecked ?? false;69---7071<span72 {...rest}73 id={id}74 data-slot="switch"75 data-size={size}76 data-default-checked={initialChecked ? "true" : undefined}77 data-name={name}78 data-value={value}79 data-unchecked-value={uncheckedValue}80 data-disabled={disabled ? "true" : undefined}81 data-read-only={readOnly ? "true" : undefined}82 data-required={required ? "true" : undefined}83 data-checked={initialChecked ? "true" : undefined}84 data-unchecked={initialChecked ? undefined : "true"}85 aria-invalid={ariaInvalid}86 class={cn(87// … truncated
Files it writes
More from bejamas/ui
All 41 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | bejamas/ui | Components | Free | 1 dep · 5 files | |
| alertalert | bejamas/ui | Components | Free | no deps · 4 files | |
| avataravatar | bejamas/ui | Components | Free | no deps · 7 files | |
| badgebadge | bejamas/ui | Components | Free | no deps · 2 files | |
| breadcrumbbreadcrumb | bejamas/ui | Components | Free | no deps · 5 files | |
| buttonbutton | bejamas/ui | Components | Free | no deps · 2 files | |
| button-groupbutton-group | bejamas/ui | Components | Free | no deps · 4 files | |
| cardcard | bejamas/ui | Components | Free | no deps · 10 files |
