mirror of
https://github.com/huntabyte/shadcn-svelte.git
synced 2026-09-14 19:33:46 +08:00
22 lines
2.5 KiB
JSON
22 lines
2.5 KiB
JSON
{
|
|
"$schema": "https://shadcn-svelte.com/schema/registry-item.json",
|
|
"name": "toggle",
|
|
"type": "registry:ui",
|
|
"devDependencies": [
|
|
"bits-ui@^2.14.4",
|
|
"@internationalized/date@^3.10.0",
|
|
"tailwind-variants@^3.2.2"
|
|
],
|
|
"files": [
|
|
{
|
|
"content": "import Root from \"./toggle.svelte\";\nexport {\n\ttoggleVariants,\n\ttype ToggleSize,\n\ttype ToggleVariant,\n\ttype ToggleVariants,\n} from \"./toggle.svelte\";\n\nexport {\n\tRoot,\n\t//\n\tRoot as Toggle,\n};\n",
|
|
"type": "registry:file",
|
|
"target": "toggle/index.ts"
|
|
},
|
|
{
|
|
"content": "<script lang=\"ts\" module>\n\timport { type VariantProps, tv } from \"tailwind-variants\";\n\n\texport const toggleVariants = tv({\n\t\tbase: \"hover:bg-muted hover:text-muted-foreground data-[state=on]:bg-accent data-[state=on]:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n\t\tvariants: {\n\t\t\tvariant: {\n\t\t\t\tdefault: \"bg-transparent\",\n\t\t\t\toutline:\n\t\t\t\t\t\"border-input hover:bg-accent hover:text-accent-foreground border bg-transparent shadow-xs\",\n\t\t\t},\n\t\t\tsize: {\n\t\t\t\tdefault: \"h-9 min-w-9 px-2\",\n\t\t\t\tsm: \"h-8 min-w-8 px-1.5\",\n\t\t\t\tlg: \"h-10 min-w-10 px-2.5\",\n\t\t\t},\n\t\t},\n\t\tdefaultVariants: {\n\t\t\tvariant: \"default\",\n\t\t\tsize: \"default\",\n\t\t},\n\t});\n\n\texport type ToggleVariant = VariantProps<typeof toggleVariants>[\"variant\"];\n\texport type ToggleSize = VariantProps<typeof toggleVariants>[\"size\"];\n\texport type ToggleVariants = VariantProps<typeof toggleVariants>;\n</script>\n\n<script lang=\"ts\">\n\timport { Toggle as TogglePrimitive } from \"bits-ui\";\n\timport { cn } from \"$UTILS$.js\";\n\n\tlet {\n\t\tref = $bindable(null),\n\t\tpressed = $bindable(false),\n\t\tclass: className,\n\t\tsize = \"default\",\n\t\tvariant = \"default\",\n\t\t...restProps\n\t}: TogglePrimitive.RootProps & {\n\t\tvariant?: ToggleVariant;\n\t\tsize?: ToggleSize;\n\t} = $props();\n</script>\n\n<TogglePrimitive.Root\n\tbind:ref\n\tbind:pressed\n\tdata-slot=\"toggle\"\n\tclass={cn(toggleVariants({ variant, size }), className)}\n\t{...restProps}\n/>\n",
|
|
"type": "registry:file",
|
|
"target": "toggle/toggle.svelte"
|
|
}
|
|
]
|
|
} |