MCPcopy Index your code
hub / github.com/adobe/react-spectrum / useMenuSection

Function useMenuSection

packages/react-aria/src/menu/useMenuSection.ts:41–64  ·  view source on GitHub ↗
(props: AriaMenuSectionProps)

Source from the content-addressed store, hash-verified

39 * @param props - Props for the section.
40 */
41export function useMenuSection(props: AriaMenuSectionProps): MenuSectionAria {
42 let {heading, 'aria-label': ariaLabel} = props;
43 let headingId = useId();
44
45 return {
46 itemProps: {
47 role: 'presentation'
48 },
49 headingProps: heading
50 ? {
51 // Techincally, menus cannot contain headings according to ARIA.
52 // We hide the heading from assistive technology, using role="presentation",
53 // and only use it as a label for the nested group.
54 id: headingId,
55 role: 'presentation'
56 }
57 : {},
58 groupProps: {
59 role: 'group',
60 'aria-label': ariaLabel,
61 'aria-labelledby': heading ? headingId : undefined
62 }
63 };
64}

Callers 2

MenuSectionInnerFunction · 0.90
MenuSectionFunction · 0.90

Calls 1

useIdFunction · 0.90

Tested by

no test coverage detected