Skip to content

Commit

Permalink
[@mantine/core] NavLink: Add react-router support to display active r…
Browse files Browse the repository at this point in the history
…oute (#6180)
  • Loading branch information
corydeppen authored May 11, 2024
1 parent 207887e commit da4139f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion apps/mantine.dev/src/pages/core/nav-link.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ export default Layout(MDX_DATA.NavLink);

## Active

Set `active` prop to add active styles to `NavLink`. You can customize active styles with `color` and `variant` props:
Set `active` prop to add active styles to `NavLink`.

Note that if you're using a React Router or Remix `NavLink` inside `renderRoot`, the active styles will be based on the
[`aria-current` attribute that's set by React Router](https://reactrouter.com/en/main/components/nav-link#aria-current)
so you won't need to explicitly set the `active` prop.

You can customize active styles with `color` and `variant` props:

<Demo data={NavLinkDemos.active} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
pointer-events: none;
}

&:where([data-active]) {
&:where([data-active], [aria-current='page']) {
background-color: var(--nl-bg);
color: var(--nl-color);

Expand Down

0 comments on commit da4139f

Please sign in to comment.