MCPcopy Create free account
hub / github.com/SwishHQ/spread / Toggle

Function Toggle

web/src/components/Toggle.tsx:13–109  ·  view source on GitHub ↗
({
    isActive,
    onChange,
    label,
    activeColor = '#34C363',
    size = 'medium',
    disabled = false
})

Source from the content-addressed store, hash-verified

11}
12
13const Toggle: React.FC<ToggleProps> = ({
14 isActive,
15 onChange,
16 label,
17 activeColor = '#34C363',
18 size = 'medium',
19 disabled = false
20}) => {
21 // Size configurations
22 const sizes = {
23 small: {
24 width: 32,
25 height: 18,
26 knobSize: 14,
27 knobOffset: 2,
28 fontSize: '12px',
29 },
30 medium: {
31 width: 42,
32 height: 22,
33 knobSize: 18,
34 knobOffset: 2,
35 fontSize: '14px',
36 },
37 large: {
38 width: 50,
39 height: 26,
40 knobSize: 22,
41 knobOffset: 2,
42 fontSize: '16px',
43 }
44 };
45
46 const { width, height, knobSize, knobOffset, fontSize } = sizes[size];
47
48 return (
49 <Flex
50 alignItems="center"
51 sx={{
52 opacity: disabled ? 0.6 : 1,
53 pointerEvents: disabled ? 'none' : 'auto',
54 }}
55 >
56 {label && (
57 <Text
58 mr={2}
59 fontSize={fontSize}
60 fontWeight="500"
61 color="#666"
62 sx={{
63 lineHeight: 1,
64 }}
65 >
66 {label}
67 </Text>
68 )}
69
70 <Box

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected