BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/docs/toggle

Toggle

docs/toggle
FreeComponent

toggle 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/toggle.json

Source

components/ui/toggle.tsxsolidcn.dev/r/toggle.json
1import { ToggleButton as KobalteToggle } from "@kobalte/core/toggle-button";
2import { type VariantProps, cva } from "class-variance-authority";
3import type { Component, ComponentProps } from "solid-js";
4import { splitProps } from "solid-js";
5import { cn } from "~/lib/utils";
6
7export const toggleVariants = cva(
8 [
9 "inline-flex items-center justify-center rounded-md text-sm font-medium",
10 "ring-offset-background transition-colors",
11 "hover:bg-muted hover:text-muted-foreground",
12 "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
13 "disabled:pointer-events-none disabled:opacity-50",
14 "data-[pressed]:bg-accent data-[pressed]:text-accent-foreground",
15 ],
16 {
17 variants: {
18 variant: {
19 default: "bg-transparent",
20 outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
21 },
22 size: {
23 default: "h-10 px-3",
24 sm: "h-9 px-2.5",
25 lg: "h-11 px-5",
26 },
27 },
28 defaultVariants: {
29 variant: "default",
30 size: "default",
31 },
32 },
33);
34
35export type ToggleProps = ComponentProps<typeof KobalteToggle> &
36 VariantProps<typeof toggleVariants> & {
37 class?: string;
38 };
39
40export const Toggle: Component<ToggleProps> = (props) => {
41 const [local, variants, rest] = splitProps(props, ["class"], ["variant", "size"]);
42 return <KobalteToggle class={cn(toggleVariants(variants), local.class)} {...rest} />;
43};

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