MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / Toggle

Function Toggle

ui/src/components/Toggle.tsx:7–28  ·  view source on GitHub ↗
({ checked, onChange, size = 'md' }: ToggleProps)

Source from the content-addressed store, hash-verified

5}
6
7export function Toggle({ checked, onChange, size = 'md' }: ToggleProps) {
8 const track = size === 'sm' ? 'w-8 h-[18px]' : 'w-10 h-[22px]'
9 const thumb = size === 'sm' ? 'w-3 h-3 bottom-[2.5px] left-[3px]' : 'w-4 h-4 bottom-[3px] left-[3px]'
10 const translate = size === 'sm' ? 'translate-x-[14px]' : 'translate-x-[18px]'
11
12 return (
13 <button
14 role="switch"
15 aria-checked={checked}
16 onClick={() => onChange(!checked)}
17 className={`relative rounded-full cursor-pointer transition-colors ${track} ${
18 checked ? 'bg-accent' : 'bg-bg-tertiary'
19 }`}
20 >
21 <span
22 className={`absolute rounded-full transition-all ${thumb} ${
23 checked ? `${translate} bg-white` : 'bg-text-muted'
24 }`}
25 />
26 </button>
27 )
28}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected