Skip to content

Commit bc97b65

Browse files
committed
docs: toggle component
1 parent 027d513 commit bc97b65

21 files changed

Lines changed: 1453 additions & 1106 deletions

File tree

packages/anatomy-icons/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { TabsAnatomy } from "./tabs"
3737
import { TagsInputAnatomy } from "./tags-input"
3838
import { ToastAnatomy } from "./toast"
3939
import { TocAnatomy } from "./toc"
40+
import { ToggleAnatomy } from "./toggle"
4041
import { ToggleGroupAnatomy } from "./toggle-group"
4142
import { TooltipAnatomy } from "./tooltip"
4243
import { TourAnatomy } from "./tour"
@@ -69,6 +70,7 @@ export const allComponents = {
6970
"segmented-control": SegmentedControlAnatomy,
7071
"tags-input": TagsInputAnatomy,
7172
"toggle-group": ToggleGroupAnatomy,
73+
toggle: ToggleAnatomy,
7274
accordion: AccordionAnatomy,
7375
avatar: AvatarAnatomy,
7476
carousel: CarouselAnatomy,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { createComponent } from "../create-component"
2+
3+
/** Single toggle: aligned with toggle-group item sizing (174×174) and canvas center (641, 319). */
4+
export const ToggleAnatomy = createComponent((props) => {
5+
const { palette, ...rest } = props
6+
return (
7+
<svg width={1456} height={812} viewBox="0 0 1456 812" fill="none" xmlns="http://www.w3.org/2000/svg" {...rest}>
8+
{/* Root — same footprint as one toggle-group item */}
9+
<rect width={174} height={174} transform="translate(641 319)" rx={12} fill={palette[5]} />
10+
{/* Indicator — inset content area */}
11+
<rect x={659} y={337} width={138} height={138} rx={10} fill={palette[4]} />
12+
{/* Bold icon — path from toggle-group, shifted to this column (641 vs 467 → +174 on x) */}
13+
<path
14+
d="M701 379H755V385H701V379ZM713 415H743V421H713V415ZM713 391H743V397H713V391ZM701 403H755V409H701V403ZM701 427H755V433H701V427Z"
15+
fill={palette[0]}
16+
/>
17+
{/* Outer dashed frame — same padding pattern as toggle-group per-item bounds */}
18+
<rect
19+
x={618.36}
20+
y={296.36}
21+
width={219.28}
22+
height={219.28}
23+
rx={14.36}
24+
stroke={palette[9]}
25+
strokeWidth={2.72}
26+
strokeDasharray="10.88 10.88"
27+
fill="none"
28+
/>
29+
<path d="M 400 406 L 641 406" stroke={palette[1]} strokeWidth={4} strokeLinecap="round" />
30+
<path d="M 797 406 L 1080 406" stroke={palette[1]} strokeWidth={4} strokeLinecap="round" />
31+
<text
32+
x={280}
33+
y={406}
34+
fill={palette[0]}
35+
fontFamily="ui-sans-serif, system-ui, sans-serif"
36+
fontSize={28}
37+
fontWeight={600}
38+
dominantBaseline="middle"
39+
>
40+
root
41+
</text>
42+
<text
43+
x={1200}
44+
y={406}
45+
fill={palette[0]}
46+
fontFamily="ui-sans-serif, system-ui, sans-serif"
47+
fontSize={28}
48+
fontWeight={600}
49+
textAnchor="end"
50+
dominantBaseline="middle"
51+
>
52+
indicator
53+
</text>
54+
</svg>
55+
)
56+
})

packages/docs/data/accessibility.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@
467467
}
468468
]
469469
},
470+
"toggle": {
471+
"keyboard": [
472+
{
473+
"keys": ["Space", "Enter"],
474+
"description": "Toggle the pressed state"
475+
}
476+
]
477+
},
470478
"toggle-group": {
471479
"keyboard": [
472480
{

0 commit comments

Comments
 (0)