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

Function SideNavItemLink

packages/@react-spectrum/s2/src/SideNav.tsx:682–708  ·  view source on GitHub ↗
(props: SideNavItemLinkProps)

Source from the content-addressed store, hash-verified

680}
681
682export const SideNavItemLink = (props: SideNavItemLinkProps): ReactNode => {
683 let {children} = props;
684 let {selectedRoute} = useContext(InternalSideNavContext);
685 let linkProps = useContext(SideNavItemLinkContext);
686
687 return (
688 <Link
689 {...props}
690 {...linkProps}
691 aria-current={selectedRoute === linkProps.href ? 'page' : undefined}
692 className={treeRowLink({isDisabled: linkProps.isDisabled})}>
693 <Provider
694 values={[
695 [TextContext, {styles: treeContent}],
696 [
697 IconContext,
698 {
699 render: centerBaseline({slot: 'icon', styles: treeIcon}),
700 styles: style({size: fontRelative(20), flexShrink: 0})
701 }
702 ]
703 ]}>
704 {typeof children === 'string' ? <Text>{children}</Text> : children}
705 </Provider>
706 </Link>
707 );
708};
709
710// The collection key of the item whose href matches `route`, or null. getKeys() covers collapsed
711// items too, and the href is stored as a data attribute so it doesn't trigger Tree's link handling.

Callers

nothing calls this directly

Calls 2

centerBaselineFunction · 0.90
fontRelativeFunction · 0.90

Tested by

no test coverage detected