NavLinkProps
react-router

NavLinkProps interface

Properties

about

Type: string

accessKey

Type: string

aria-activedescendant

Type: string

Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.

aria-atomic

Type: Booleanish

Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.

aria-autocomplete

Type: "none" | "list" | "inline" | "both"

Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be presented if they are made.

aria-braillelabel

Type: string

Defines a string value that labels the current element, which is intended to be converted into Braille.

aria-brailleroledescription

Type: string

Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.

aria-busy

Type: Booleanish

aria-checked

Type: boolean | "true" | "false" | "mixed"

Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.

aria-colcount

Type: number

Defines the total number of columns in a table, grid, or treegrid.

aria-colindex

Type: number

Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.

aria-colindextext

Type: string

Defines a human readable text alternative of aria-colindex.

aria-colspan

Type: number

Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.

aria-controls

Type: string

Identifies the element (or elements) whose contents or presence are controlled by the current element.

aria-current

Type: boolean | "time" | "true" | "location" | "page" | "step" | "false" | "date"

Indicates the element that represents the current item within a container or set of related elements.

aria-describedby

Type: string

Identifies the element (or elements) that describes the object.

aria-description

Type: string

Defines a string value that describes or annotates the current element.

aria-details

Type: string

Identifies the element that provides a detailed, extended description for the object.

aria-disabled

Type: Booleanish

Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.

aria-dropeffect

Type: "link" | "copy" | "none" | "execute" | "move" | "popup"

Indicates what functions can be performed when a dragged object is released on the drop target.

aria-errormessage

Type: string

Identifies the element that provides an error message for the object.

aria-expanded

Type: Booleanish

Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.

aria-flowto

Type: string

Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, allows assistive technology to override the general default of reading in document source order.

aria-grabbed

Type: Booleanish

Indicates an element's "grabbed" state in a drag-and-drop operation.

aria-haspopup

Type: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree"

Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.

aria-hidden

Type: Booleanish

Indicates whether the element is exposed to an accessibility API.

aria-invalid

Type: boolean | "true" | "false" | "grammar" | "spelling"

Indicates the entered value does not conform to the format expected by the application.

aria-keyshortcuts

Type: string

Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.

aria-label

Type: string

Defines a string value that labels the current element.

aria-labelledby

Type: string

Identifies the element (or elements) that labels the current element.

aria-level

Type: number

Defines the hierarchical level of an element within a structure.

aria-live

Type: "off" | "assertive" | "polite"

Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.

aria-modal

Type: Booleanish

Indicates whether an element is modal when displayed.

aria-multiline

Type: Booleanish

Indicates whether a text box accepts multiple lines of input or only a single line.

aria-multiselectable

Type: Booleanish

Indicates that the user may select more than one item from the current selectable descendants.

aria-orientation

Type: "horizontal" | "vertical"

Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.

aria-owns

Type: string

Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship.

aria-placeholder

Type: string

Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format.

aria-posinset

Type: number

Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.

aria-pressed

Type: boolean | "true" | "false" | "mixed"

Indicates the current "pressed" state of toggle buttons.

aria-readonly

Type: Booleanish

Indicates that the element is not editable, but is otherwise operable.

aria-relevant

Type: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals"

Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.

aria-required

Type: Booleanish

Indicates that user input is required on the element before a form may be submitted.

aria-roledescription

Type: string

Defines a human-readable, author-localized description for the role of an element.

aria-rowcount

Type: number

Defines the total number of rows in a table, grid, or treegrid.

aria-rowindex

Type: number

Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.

aria-rowindextext

Type: string

Defines a human readable text alternative of aria-rowindex.

aria-rowspan

Type: number

Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.

aria-selected

Type: Booleanish

Indicates the current "selected" state of various widgets.

aria-setsize

Type: number

Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.

aria-sort

Type: "none" | "ascending" | "descending" | "other"

Indicates if items in a table or grid are sorted in ascending or descending order.

aria-valuemax

Type: number

Defines the maximum allowed value for a range widget.

aria-valuemin

Type: number

Defines the minimum allowed value for a range widget.

aria-valuenow

Type: number

Defines the current value for a range widget.

aria-valuetext

Type: string

Defines the human readable text alternative of aria-valuenow for a range widget.

autoCapitalize

Type: string

autoCorrect

Type: string

autoFocus

Type: boolean

autoSave

Type: string

caseSensitive

Type: boolean

Changes the matching logic to make it case-sensitive:

Link URL isActive
<NavLink to="/SpOnGe-bOB" /> /sponge-bob true
<NavLink to="/SpOnGe-bOB" caseSensitive /> /sponge-bob false

children

Type: ReactNode | { }

Can be regular React children or a function that receives an object with the active and pending states of the link.

<NavLink to="/tasks">
  {({ isActive }) => (
    <span className={isActive ? "active" : ""}>Tasks</span>
  )}
</NavLink>

className

Type: string | { }

Classes are automatically applied to NavLink that correspond to NavLinkRenderProps.

a.active { color: red; }
a.pending { color: blue; }
a.transitioning {
  view-transition-name: my-transition;
}

color

Type: string

content

Type: string

contentEditable

Type: "inherit" | Booleanish

contextMenu

Type: string

dangerouslySetInnerHTML

Type: { __html: string | TrustedHTML, }

datatype

Type: string

defaultChecked

Type: boolean

defaultValue

Type: string | number | readonly string[]

dir

Type: string

discover

Type: DiscoverBehavior

Defines the link discovery behavior

<Link /> // default ("render")
<Link discover="render" />
<Link discover="none" />
  • render - default, discover the route when the link renders
  • none - don't eagerly discover, only discover if the link is clicked

download

Type: any

draggable

Type: Booleanish

end

Type: boolean

Changes the matching logic for the active and pending states to only match to the "end" of the NavLinkProps.to. If the URL is longer, it will no longer be considered active.

Link URL isActive
<NavLink to="/tasks" /> /tasks true
<NavLink to="/tasks" /> /tasks/123 true
<NavLink to="/tasks" end /> /tasks true
<NavLink to="/tasks" end /> /tasks/123 false

<NavLink to="/"> is an exceptional case because every URL matches /. To avoid this matching every single route by default, it effectively ignores the end prop and only matches when you're at the root route.

hidden

Type: boolean

hrefLang

Type: string

id

Type: string

inlist

Type: any

inputMode

Type: "search" | "text" | "url" | "none" | "tel" | "email" | "numeric" | "decimal"

Hints at the type of data that might be entered by the user while editing the element or its contents

is

Type: string

Specify that a standard HTML element should behave like a defined custom built-in element

itemID

Type: string

itemProp

Type: string

itemRef

Type: string

itemScope

Type: boolean

itemType

Type: string

lang

Type: string

media

Type: string

nonce

Type: string

onAbort

Type: ReactEventHandler<HTMLAnchorElement>

onAbortCapture

Type: ReactEventHandler<HTMLAnchorElement>

onAnimationEnd

Type: AnimationEventHandler<HTMLAnchorElement>

onAnimationEndCapture

Type: AnimationEventHandler<HTMLAnchorElement>

onAnimationIteration

Type: AnimationEventHandler<HTMLAnchorElement>

onAnimationIterationCapture

Type: AnimationEventHandler<HTMLAnchorElement>

onAnimationStart

Type: AnimationEventHandler<HTMLAnchorElement>

onAnimationStartCapture

Type: AnimationEventHandler<HTMLAnchorElement>

onAuxClick

Type: MouseEventHandler<HTMLAnchorElement>

onAuxClickCapture

Type: MouseEventHandler<HTMLAnchorElement>

onBeforeInput

Type: FormEventHandler<HTMLAnchorElement>

onBeforeInputCapture

Type: FormEventHandler<HTMLAnchorElement>

onBlur

Type: FocusEventHandler<HTMLAnchorElement>

onBlurCapture

Type: FocusEventHandler<HTMLAnchorElement>

onCanPlay

Type: ReactEventHandler<HTMLAnchorElement>

onCanPlayCapture

Type: ReactEventHandler<HTMLAnchorElement>

onCanPlayThrough

Type: ReactEventHandler<HTMLAnchorElement>

onCanPlayThroughCapture

Type: ReactEventHandler<HTMLAnchorElement>

onChange

Type: FormEventHandler<HTMLAnchorElement>

onChangeCapture

Type: FormEventHandler<HTMLAnchorElement>

onClick

Type: MouseEventHandler<HTMLAnchorElement>

onClickCapture

Type: MouseEventHandler<HTMLAnchorElement>

onCompositionEnd

Type: CompositionEventHandler<HTMLAnchorElement>

onCompositionEndCapture

Type: CompositionEventHandler<HTMLAnchorElement>

onCompositionStart

Type: CompositionEventHandler<HTMLAnchorElement>

onCompositionStartCapture

Type: CompositionEventHandler<HTMLAnchorElement>

onCompositionUpdate

Type: CompositionEventHandler<HTMLAnchorElement>

onCompositionUpdateCapture

Type: CompositionEventHandler<HTMLAnchorElement>

onContextMenu

Type: MouseEventHandler<HTMLAnchorElement>

onContextMenuCapture

Type: MouseEventHandler<HTMLAnchorElement>

onCopy

Type: ClipboardEventHandler<HTMLAnchorElement>

onCopyCapture

Type: ClipboardEventHandler<HTMLAnchorElement>

onCut

Type: ClipboardEventHandler<HTMLAnchorElement>

onCutCapture

Type: ClipboardEventHandler<HTMLAnchorElement>

onDoubleClick

Type: MouseEventHandler<HTMLAnchorElement>

onDoubleClickCapture

Type: MouseEventHandler<HTMLAnchorElement>

onDrag

Type: DragEventHandler<HTMLAnchorElement>

onDragCapture

Type: DragEventHandler<HTMLAnchorElement>

onDragEnd

Type: DragEventHandler<HTMLAnchorElement>

onDragEndCapture

Type: DragEventHandler<HTMLAnchorElement>

onDragEnter

Type: DragEventHandler<HTMLAnchorElement>

onDragEnterCapture

Type: DragEventHandler<HTMLAnchorElement>

onDragExit

Type: DragEventHandler<HTMLAnchorElement>

onDragExitCapture

Type: DragEventHandler<HTMLAnchorElement>

onDragLeave

Type: DragEventHandler<HTMLAnchorElement>

onDragLeaveCapture

Type: DragEventHandler<HTMLAnchorElement>

onDragOver

Type: DragEventHandler<HTMLAnchorElement>

onDragOverCapture

Type: DragEventHandler<HTMLAnchorElement>

onDragStart

Type: DragEventHandler<HTMLAnchorElement>

onDragStartCapture

Type: DragEventHandler<HTMLAnchorElement>

onDrop

Type: DragEventHandler<HTMLAnchorElement>

onDropCapture

Type: DragEventHandler<HTMLAnchorElement>

onDurationChange

Type: ReactEventHandler<HTMLAnchorElement>

onDurationChangeCapture

Type: ReactEventHandler<HTMLAnchorElement>

onEmptied

Type: ReactEventHandler<HTMLAnchorElement>

onEmptiedCapture

Type: ReactEventHandler<HTMLAnchorElement>

onEncrypted

Type: ReactEventHandler<HTMLAnchorElement>

onEncryptedCapture

Type: ReactEventHandler<HTMLAnchorElement>

onEnded

Type: ReactEventHandler<HTMLAnchorElement>

onEndedCapture

Type: ReactEventHandler<HTMLAnchorElement>

onError

Type: ReactEventHandler<HTMLAnchorElement>

onErrorCapture

Type: ReactEventHandler<HTMLAnchorElement>

onFocus

Type: FocusEventHandler<HTMLAnchorElement>

onFocusCapture

Type: FocusEventHandler<HTMLAnchorElement>

onGotPointerCapture

Type: PointerEventHandler<HTMLAnchorElement>

onGotPointerCaptureCapture

Type: PointerEventHandler<HTMLAnchorElement>

onInput

Type: FormEventHandler<HTMLAnchorElement>

onInputCapture

Type: FormEventHandler<HTMLAnchorElement>

onInvalid

Type: FormEventHandler<HTMLAnchorElement>

onInvalidCapture

Type: FormEventHandler<HTMLAnchorElement>

onKeyDown

Type: KeyboardEventHandler<HTMLAnchorElement>

onKeyDownCapture

Type: KeyboardEventHandler<HTMLAnchorElement>

onKeyPress

Type: KeyboardEventHandler<HTMLAnchorElement>

onKeyPressCapture

Type: KeyboardEventHandler<HTMLAnchorElement>

onKeyUp

Type: KeyboardEventHandler<HTMLAnchorElement>

onKeyUpCapture

Type: KeyboardEventHandler<HTMLAnchorElement>

onLoad

Type: ReactEventHandler<HTMLAnchorElement>

onLoadCapture

Type: ReactEventHandler<HTMLAnchorElement>

onLoadStart

Type: ReactEventHandler<HTMLAnchorElement>

onLoadStartCapture

Type: ReactEventHandler<HTMLAnchorElement>

onLoadedData

Type: ReactEventHandler<HTMLAnchorElement>

onLoadedDataCapture

Type: ReactEventHandler<HTMLAnchorElement>

onLoadedMetadata

Type: ReactEventHandler<HTMLAnchorElement>

onLoadedMetadataCapture

Type: ReactEventHandler<HTMLAnchorElement>

onLostPointerCapture

Type: PointerEventHandler<HTMLAnchorElement>

onLostPointerCaptureCapture

Type: PointerEventHandler<HTMLAnchorElement>

onMouseDown

Type: MouseEventHandler<HTMLAnchorElement>

onMouseDownCapture

Type: MouseEventHandler<HTMLAnchorElement>

onMouseEnter

Type: MouseEventHandler<HTMLAnchorElement>

onMouseLeave

Type: MouseEventHandler<HTMLAnchorElement>

onMouseMove

Type: MouseEventHandler<HTMLAnchorElement>

onMouseMoveCapture

Type: MouseEventHandler<HTMLAnchorElement>

onMouseOut

Type: MouseEventHandler<HTMLAnchorElement>

onMouseOutCapture

Type: MouseEventHandler<HTMLAnchorElement>

onMouseOver

Type: MouseEventHandler<HTMLAnchorElement>

onMouseOverCapture

Type: MouseEventHandler<HTMLAnchorElement>

onMouseUp

Type: MouseEventHandler<HTMLAnchorElement>

onMouseUpCapture

Type: MouseEventHandler<HTMLAnchorElement>

onPaste

Type: ClipboardEventHandler<HTMLAnchorElement>

onPasteCapture

Type: ClipboardEventHandler<HTMLAnchorElement>

onPause

Type: ReactEventHandler<HTMLAnchorElement>

onPauseCapture

Type: ReactEventHandler<HTMLAnchorElement>

onPlay

Type: ReactEventHandler<HTMLAnchorElement>

onPlayCapture

Type: ReactEventHandler<HTMLAnchorElement>

onPlaying

Type: ReactEventHandler<HTMLAnchorElement>

onPlayingCapture

Type: ReactEventHandler<HTMLAnchorElement>

onPointerCancel

Type: PointerEventHandler<HTMLAnchorElement>

onPointerCancelCapture

Type: PointerEventHandler<HTMLAnchorElement>

onPointerDown

Type: PointerEventHandler<HTMLAnchorElement>

onPointerDownCapture

Type: PointerEventHandler<HTMLAnchorElement>

onPointerEnter

Type: PointerEventHandler<HTMLAnchorElement>

onPointerEnterCapture

Type: PointerEventHandler<HTMLAnchorElement>

onPointerLeave

Type: PointerEventHandler<HTMLAnchorElement>

onPointerLeaveCapture

Type: PointerEventHandler<HTMLAnchorElement>

onPointerMove

Type: PointerEventHandler<HTMLAnchorElement>

onPointerMoveCapture

Type: PointerEventHandler<HTMLAnchorElement>

onPointerOut

Type: PointerEventHandler<HTMLAnchorElement>

onPointerOutCapture

Type: PointerEventHandler<HTMLAnchorElement>

onPointerOver

Type: PointerEventHandler<HTMLAnchorElement>

onPointerOverCapture

Type: PointerEventHandler<HTMLAnchorElement>

onPointerUp

Type: PointerEventHandler<HTMLAnchorElement>

onPointerUpCapture

Type: PointerEventHandler<HTMLAnchorElement>

onProgress

Type: ReactEventHandler<HTMLAnchorElement>

onProgressCapture

Type: ReactEventHandler<HTMLAnchorElement>

onRateChange

Type: ReactEventHandler<HTMLAnchorElement>

onRateChangeCapture

Type: ReactEventHandler<HTMLAnchorElement>

onReset

Type: FormEventHandler<HTMLAnchorElement>

onResetCapture

Type: FormEventHandler<HTMLAnchorElement>

onResize

Type: ReactEventHandler<HTMLAnchorElement>

onResizeCapture

Type: ReactEventHandler<HTMLAnchorElement>

onScroll

Type: UIEventHandler<HTMLAnchorElement>

onScrollCapture

Type: UIEventHandler<HTMLAnchorElement>

onSeeked

Type: ReactEventHandler<HTMLAnchorElement>

onSeekedCapture

Type: ReactEventHandler<HTMLAnchorElement>

onSeeking

Type: ReactEventHandler<HTMLAnchorElement>

onSeekingCapture

Type: ReactEventHandler<HTMLAnchorElement>

onSelect

Type: ReactEventHandler<HTMLAnchorElement>

onSelectCapture

Type: ReactEventHandler<HTMLAnchorElement>

onStalled

Type: ReactEventHandler<HTMLAnchorElement>

onStalledCapture

Type: ReactEventHandler<HTMLAnchorElement>

onSubmit

Type: FormEventHandler<HTMLAnchorElement>

onSubmitCapture

Type: FormEventHandler<HTMLAnchorElement>

onSuspend

Type: ReactEventHandler<HTMLAnchorElement>

onSuspendCapture

Type: ReactEventHandler<HTMLAnchorElement>

onTimeUpdate

Type: ReactEventHandler<HTMLAnchorElement>

onTimeUpdateCapture

Type: ReactEventHandler<HTMLAnchorElement>

onTouchCancel

Type: TouchEventHandler<HTMLAnchorElement>

onTouchCancelCapture

Type: TouchEventHandler<HTMLAnchorElement>

onTouchEnd

Type: TouchEventHandler<HTMLAnchorElement>

onTouchEndCapture

Type: TouchEventHandler<HTMLAnchorElement>

onTouchMove

Type: TouchEventHandler<HTMLAnchorElement>

onTouchMoveCapture

Type: TouchEventHandler<HTMLAnchorElement>

onTouchStart

Type: TouchEventHandler<HTMLAnchorElement>

onTouchStartCapture

Type: TouchEventHandler<HTMLAnchorElement>

onTransitionEnd

Type: TransitionEventHandler<HTMLAnchorElement>

onTransitionEndCapture

Type: TransitionEventHandler<HTMLAnchorElement>

onVolumeChange

Type: ReactEventHandler<HTMLAnchorElement>

onVolumeChangeCapture

Type: ReactEventHandler<HTMLAnchorElement>

onWaiting

Type: ReactEventHandler<HTMLAnchorElement>

onWaitingCapture

Type: ReactEventHandler<HTMLAnchorElement>

onWheel

Type: WheelEventHandler<HTMLAnchorElement>

onWheelCapture

Type: WheelEventHandler<HTMLAnchorElement>

ping

Type: string

placeholder

Type: string

prefetch

Type: PrefetchBehavior

Defines the data and module prefetching behavior for the link.

<Link /> // default
<Link prefetch="none" />
<Link prefetch="intent" />
<Link prefetch="render" />
<Link prefetch="viewport" />
  • none - default, no prefetching
  • intent - prefetches when the user hovers or focuses the link
  • render - prefetches when the link renders
  • viewport - prefetches when the link is in the viewport, very useful for mobile

Prefetching is done with HTML <link rel="prefetch"> tags. They are inserted after the link.

<a href="..." />
<a href="..." />
<link rel="prefetch" /> // might conditionally render

Because of this, if you are using nav :last-child you will need to use nav :last-of-type so the styles don't conditionally fall off your last link (and any other similar selectors).

prefix

Type: string

preventScrollReset

Type: boolean

Prevents the scroll position from being reset to the top of the window when the link is clicked and the app is using ScrollRestoration. This only prevents new locations reseting scroll to the top, scroll position will be restored for back/forward button navigation.

<Link to="?tab=one" preventScrollReset />

property

Type: string

radioGroup

Type: string

referrerPolicy

Type: HTMLAttributeReferrerPolicy

rel

Type: string

relative

Type: RelativeRoutingType

Defines the relative path behavior for the link.

<Link to=".." /> // default: "route"
<Link relative="route" />
<Link relative="path" />

Consider a route hierarchy where a parent route pattern is "blog" and a child route pattern is "blog/:slug/edit".

  • route - default, resolves the link relative to the route pattern. In the example above a relative link of ".." will remove both :slug/edit segments back to "/blog".
  • path - relative to the path so .. will only remove one URL segment up to "/blog/:slug"

reloadDocument

Type: boolean

Will use document navigation instead of client side routing when the link is clicked: the browser will handle the transition normally (as if it were an <a href>).

<Link to="/logout" reloadDocument />

replace

Type: boolean

Replaces the current entry in the history stack instead of pushing a new one onto it.

<Link replace />
# with a history stack like this
A -> B

# normal link click pushes a new entry
A -> B -> C

# but with `replace`, B is replaced by C
A -> C

resource

Type: string

results

Type: number

rev

Type: string

role

Type: AriaRole

security

Type: string

slot

Type: string

spellCheck

Type: Booleanish

state

Type: any

Adds persistent client side routing state to the next location.

<Link to="/somewhere/else" state={{ some: "value" }} />

The location state is accessed from the location.

function SomeComp() {
  const location = useLocation()
  location.state; // { some: "value" }
}

This state is inaccessible on the server as it is implemented on top of history.state

style

Type: CSSProperties | { }

suppressContentEditableWarning

Type: boolean

suppressHydrationWarning

Type: boolean

tabIndex

Type: number

target

Type: HTMLAttributeAnchorTarget

title

Type: string

to

Type: To

Can be a string or a partial Path:

<Link to="/some/path" />

<Link
  to={{
    pathname: "/some/path",
    search: "?query=string",
    hash: "#hash",
  }}
/>

translate

Type: "yes" | "no"

type

Type: string

typeof

Type: string

unselectable

Type: "on" | "off"

viewTransition

Type: boolean

Enables a View Transition for this navigation.

<Link to={to} viewTransition>
  Click me
</Link>

To apply specific styles for the transition, see useViewTransitionState

vocab

Type: string

Docs and examples CC 4.0