BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/docs/switch

Switch

docs/switch
FreeComponent

switch component for SolidJS

Live preview

live · rendered by the registry
Rendered by docs on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://solidcn.dev/r/switch.json

Source

components/ui/switch.tsxsolidcn.dev/r/switch.json
1import { Switch as KobalteSwitch } from "@kobalte/core/switch";
2import type { Component, ComponentProps } from "solid-js";
3import { splitProps } from "solid-js";
4import { cn } from "~/lib/utils";
5
6export type SwitchProps = ComponentProps<typeof KobalteSwitch> & {
7 label?: string;
8 class?: string;
9};
10
11export const Switch: Component<SwitchProps> = (props) => {
12 const [local, rest] = splitProps(props, ["class", "label"]);
13
14 return (
15 <KobalteSwitch class={cn("flex items-center gap-2", local.class)} {...rest}>
16 <KobalteSwitch.Input class="sr-only" />
17 <KobalteSwitch.Control
18 class={cn(
19 "inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent",
20 "transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
21 "disabled:cursor-not-allowed disabled:opacity-50",
22 "bg-input data-[checked]:bg-primary",
23 )}
24 >
25 <KobalteSwitch.Thumb
26 class={cn(
27 "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform",
28 "translate-x-0 data-[checked]:translate-x-5",
29 )}
30 />
31 </KobalteSwitch.Control>
32 {local.label && (
33 <KobalteSwitch.Label class="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
34 {local.label}
35 </KobalteSwitch.Label>
36 )}
37 </KobalteSwitch>
38 );
39};

Facts

Registry
docs
Type
registry:ui
Access
Free
Files written
0
Licence
MIT
First indexed
2026-08-01
Last confirmed
2 days ago

Go to the source

Docs on docs solidcn.dev solidcn-ui/solidcn on GitHub Raw registry item This item as JSON

More from docs

All 44 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordiondocsComponentsFreeno deps
Alert Dialogalert-dialogdocsComponentsFreeno deps
AvataravatardocsComponentsFreeno deps
BadgebadgedocsComponentsFreeno deps
BreadcrumbbreadcrumbdocsComponentsFreeno deps
ButtonbuttondocsComponentsFreeno deps
CalendarcalendardocsComponentsFreeno deps
CardcarddocsComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex