snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
46
apps/v4/registry/bases/aria/ui/toggle.tsx
Normal file
46
apps/v4/registry/bases/aria/ui/toggle.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
"use client"
|
||||
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { cn } from "cn"
|
||||
import {
|
||||
ToggleButton as TogglePrimitive,
|
||||
type ToggleButtonProps,
|
||||
} from "react-aria-components"
|
||||
|
||||
const toggleVariants = cva(
|
||||
"cn-toggle cn-toggle-aria group/toggle inline-flex items-center justify-center whitespace-nowrap outline-none hover:bg-muted focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "cn-toggle-variant-default",
|
||||
outline: "cn-toggle-variant-outline",
|
||||
},
|
||||
size: {
|
||||
default: "cn-toggle-size-default",
|
||||
sm: "cn-toggle-size-sm",
|
||||
lg: "cn-toggle-size-lg",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Toggle({
|
||||
className,
|
||||
variant = "default",
|
||||
size = "default",
|
||||
...props
|
||||
}: ToggleButtonProps & VariantProps<typeof toggleVariants>) {
|
||||
return (
|
||||
<TogglePrimitive
|
||||
data-slot="toggle"
|
||||
className={cn(toggleVariants({ variant, size, className }))}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Toggle, toggleVariants }
|
||||
Reference in New Issue
Block a user