MCPcopy Create free account
hub / github.com/adobe/react-spectrum / useSeparator

Function useSeparator

packages/react-aria/src/separator/useSeparator.ts:37–56  ·  view source on GitHub ↗
(props: SeparatorProps)

Source from the content-addressed store, hash-verified

35 * e.g. groups of menu items or sections of a page.
36 */
37export function useSeparator(props: SeparatorProps): SeparatorAria {
38 let domProps = filterDOMProps(props, {labelable: true});
39 let ariaOrientation;
40 // if orientation is horizontal, aria-orientation default is horizontal, so we leave it undefined
41 // if it's vertical, we need to specify it
42 if (props.orientation === 'vertical') {
43 ariaOrientation = 'vertical';
44 }
45 // hr elements implicitly have role = separator and a horizontal orientation
46 if (props.elementType !== 'hr') {
47 return {
48 separatorProps: {
49 ...domProps,
50 role: 'separator',
51 'aria-orientation': ariaOrientation
52 }
53 };
54 }
55 return {separatorProps: domProps};
56}

Callers 3

Separator.tsxFile · 0.90
Divider.tsxFile · 0.90
MenuSectionFunction · 0.90

Calls 1

filterDOMPropsFunction · 0.90

Tested by

no test coverage detected