toggle.tsx
This file
Path
apps/web/src/components/ui/toggle.tsx
44 lines · 1.6 KiB · TypeScript
Last changed by
Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
History of this fileTake it
Give the web its W9 dependencies, components, project nav, line and revision helpers, and a stub for every new pageoscabrielbefore adoption254268a
lines 1–7why, one step back1"use client";23import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";4import { cva, type VariantProps } from "class-variance-authority";5import { cn } from "cn";67const toggleVariants = cva(Draw text, controls, prose and code from one set of tokensoscabrielbefore adoption60f862e
line 8why, one step back8 "group/toggle hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 text-ui inline-flex items-center justify-center gap-1 rounded-none font-medium whitespace-nowrap transition-all 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",Give the web its W9 dependencies, components, project nav, line and revision helpers, and a stub for every new pageoscabrielbefore adoption254268a
lines 9–44why, one step back9 {10 variants: {11 variant: {12 default: "bg-transparent",13 outline: "border-input hover:bg-muted border bg-transparent",14 },15 size: {16 default:17 "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",18 sm: "h-7 min-w-7 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",19 lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",20 },21 },22 defaultVariants: {23 variant: "default",24 size: "default",25 },26 }27);2829function Toggle({30 className,31 variant = "default",32 size = "default",33 ...props34}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {35 return (36 <TogglePrimitive37 data-slot="toggle"38 className={cn(toggleVariants({ variant, size, className }))}39 {...props}40 />41 );42}4344export { Toggle, toggleVariants };