The object passed to NavLink children, className, and style prop callbacks to render and style the link based on its state.
children
className
style
// className<NavLink to="/messages" className={({ isActive, isPending }) => isPending ? "pending" : isActive ? "active" : "" }> Messages</NavLink>// style<NavLink to="/messages" style={({ isActive, isPending }) => { return { fontWeight: isActive ? "bold" : "", color: isPending ? "red" : "black", } )}/>// children<NavLink to="/tasks"> {({ isActive, isPending }) => ( <span className={isActive ? "active" : ""}>Tasks</span> )}</NavLink> Copy
// className<NavLink to="/messages" className={({ isActive, isPending }) => isPending ? "pending" : isActive ? "active" : "" }> Messages</NavLink>// style<NavLink to="/messages" style={({ isActive, isPending }) => { return { fontWeight: isActive ? "bold" : "", color: isPending ? "red" : "black", } )}/>// children<NavLink to="/tasks"> {({ isActive, isPending }) => ( <span className={isActive ? "active" : ""}>Tasks</span> )}</NavLink>
Indicates if the link's URL matches the current location.
Indicates if the pending location matches the link's URL.
Indicates if a view transition to the link's URL is in progress. See useViewTransitionState
The object passed to NavLink
children
,className
, andstyle
prop callbacks to render and style the link based on its state.