MCPcopy Create free account
hub / github.com/better-auth/examples / SwitchControl

Function SwitchControl

astro-example/src/components/ui/switch.tsx:20–42  ·  view source on GitHub ↗
(
	props: PolymorphicProps<T, switchControlProps<T>>,
)

Source from the content-addressed store, hash-verified

18>;
19
20export const SwitchControl = <T extends ValidComponent = "input">(
21 props: PolymorphicProps<T, switchControlProps<T>>,
22) => {
23 const [local, rest] = splitProps(props as switchControlProps, [
24 "class",
25 "children",
26 ]);
27
28 return (
29 <>
30 <SwitchPrimitive.Input class="[&:focus-visible+div]:outline-none [&:focus-visible+div]:ring-[1.5px] [&:focus-visible+div]:ring-ring [&:focus-visible+div]:ring-offset-2 [&:focus-visible+div]:ring-offset-background" />
31 <SwitchPrimitive.Control
32 class={cn(
33 "inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent bg-input shadow-sm transition-[color,background-color,box-shadow] data-[disabled]:cursor-not-allowed data-[checked]:bg-primary data-[disabled]:opacity-50",
34 local.class,
35 )}
36 {...rest}
37 >
38 {local.children}
39 </SwitchPrimitive.Control>
40 </>
41 );
42};
43
44type switchThumbProps<T extends ValidComponent = "div"> = VoidProps<
45 SwitchThumbProps<T> & { class?: string }

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected