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

Function NavigationTreeItemContent

starters/tailwind/src/NavigationTree.tsx:105–139  ·  view source on GitHub ↗
(props: {children?: React.ReactNode})

Source from the content-addressed store, hash-verified

103const RenderLinkContext = React.createContext<LinkProps['render'] | undefined>(undefined);
104
105export function NavigationTreeItemContent(props: {children?: React.ReactNode}) {
106 return (
107 <AriaNavigationTreeItemContent>
108 {({level, hasChildItems, isExpanded, isCurrent, isCurrentAncestor}) => {
109 let indicator: 'current' | 'ancestor' | undefined;
110 if (isCurrent) {
111 indicator = 'current';
112 } else if (isCurrentAncestor && !isExpanded) {
113 indicator = 'ancestor';
114 }
115 return (
116 <>
117 {level > 1 && (
118 <div
119 className="shrink-0"
120 style={{width: `calc((${level} - 1) * calc(var(--spacing) * 4))`}}
121 />
122 )}
123 <NavTreeLinkContext.Provider value={{indicator}}>
124 {props.children}
125 </NavTreeLinkContext.Provider>
126 <Button
127 slot="chevron"
128 isDisabled={!hasChildItems}
129 className={({isFocusVisible}) =>
130 expandButton({isFocusVisible, className: hasChildItems ? undefined : 'invisible'})
131 }>
132 <ChevronRight aria-hidden className={chevron({isExpanded})} />
133 </Button>
134 </>
135 );
136 }}
137 </AriaNavigationTreeItemContent>
138 );
139}
140
141export function NavigationTreeItem(props: AriaNavigationTreeItemProps) {
142 return <AriaNavigationTreeItem className={itemStyles} {...props} />;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected