Usage
Active
Set active
prop to add active styles to NavLink
. You can customize active styles with color
and variant
props:
Color
Variant
Nested NavLinks
To create nested links put NavLink
as children of another NavLink
:
Polymorphic component
NavLink
is a polymorphic component, by default, its root element is button
you can change that by setting component
prop:
NavLink component props
Name | Type | Description |
---|---|---|
active | boolean | Determines whether link should have active styles |
children | ReactNode | Child links |
childrenOffset | number | "xs" | "sm" | "md" | "lg" | "xl" | Key of theme.spacing or any valid CSS value to set collapsed links padding-left |
color | MantineColor | Key of theme.colors, active link color |
defaultOpened | boolean | Uncontrolled nested items collapse initial state |
description | ReactNode | Secondary link description |
disableRightSectionRotation | boolean | If set to true, right section will not rotate when collapse is opened |
disabled | boolean | Adds disabled styles to root element |
icon | ReactNode | Icon displayed on the left side of the label |
label | ReactNode | Main link content |
noWrap | boolean | If prop is set then label and description will not wrap on the next line |
onChange | (opened: boolean) => void | Called when open state changes |
opened | boolean | Controlled nested items collapse state |
rightSection | ReactNode | Section displayed on the right side of the label |
variant | Variants<"light" | "filled" | "subtle"> | Active link variant |
NavLink component Styles API
Name | Static selector | Description |
---|---|---|
root | .mantine-NavLink-root | Root element |
body | .mantine-NavLink-body | Contains label and description |
icon | .mantine-NavLink-icon | Icon on the left side of the body |
rightSection | .mantine-NavLink-rightSection | Section on the right side of the body |
label | .mantine-NavLink-label | Label |
description | .mantine-NavLink-description | Dimmed description displayed below the label |
children | .mantine-NavLink-children | Wrapper around nested links |