Anatomy
Label the parts of a live component with numbers and describe each one below it.
Anatomy shows a component with its named parts labelled over it, and a list
below that says what each part is. The component is the real one, not a
picture: it still works, and the labels move with it. Press the heading below
to open it.
-
rootThe box around everything. It holds the open state. -
triggerThe button the reader presses. It says whether the details are open with
aria-expanded. -
titleThe heading text, from the
titleprop. -
indicatorThe chevron. It turns over when the details open. -
contentThe details. They are only in the page while open, so this part is labelled only then.
Usage
Mark each part of the component with a data-part attribute. Then put the
component in Anatomy, and describe each part with a Part in the parts snippet. Each Part matches the element whose data-part has the same name.
Parts are numbered in the order the Parts are written, so write them in the
order you want them read. A Part can hold markdown, code and links: leave a
blank line after its opening tag and before its closing one, as you would in a Callout.
Labels follow the component
The labels are drawn on top of the real component, so a reader can use it. A click on a label goes through to the component under it. When the component changes size or state, the labels move with it, and a part that leaves the page loses its label until it comes back.
Pointing at a part in the list, or tabbing into it, outlines that part on the component. The Hide labels button below the component takes the labels away so the reader can try it without them.
Parts it can’t label
A part has to be inside Anatomy to be labelled. A popover, menu or tooltip
that renders into <body> (a portal) is outside it, so it gets no label. You
can still describe it with a Part; its number shows in the list only.
In development, the console warns about a data-part that has no Part, and
about a Part that matches no data-part. A data-part with no Part is
still labelled. It is numbered after the Parts.
For agents
Agents read the page as written, so they see the component’s tag and each Part with its description, in order.
Props
children required Snippet data-part="name".parts Snippet <Part name="…"> for each part, in the order to number them.name required string data-part value it describes.children Snippet