Files
upstream-shadcn-ui/apps/v4/registry/bases/aria/ui/switch.tsx
upstream-mirror 1416db152c
All checks were successful
Release / Create Version PR or Publish Stable Release (push) Has been skipped
Release / Publish Prerelease to NPM (push) Has been skipped
Monitor Registries / Monitor registry health (push) Has been skipped
snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:44:43 +05:00

43 lines
1.1 KiB
TypeScript

"use client"
import { cn } from "cn"
import {
composeRenderProps,
Switch as SwitchPrimitive,
type SwitchProps as SwitchPrimitiveProps,
} from "react-aria-components"
function Switch({
className,
size = "default",
children,
...props
}: SwitchPrimitiveProps & {
size?: "sm" | "default"
}) {
return (
<SwitchPrimitive
data-slot="switch"
data-size={size}
className={cn(
"cn-switch cn-switch-aria peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-50",
className
)}
{...props}
>
{composeRenderProps(children, (children, { isSelected }) => (
<>
<span
data-slot="switch-thumb"
data-selected={isSelected || undefined}
className="cn-switch-thumb cn-switch-thumb-aria pointer-events-none block ring-0 transition-transform"
/>
{children}
</>
))}
</SwitchPrimitive>
)
}
export { Switch }