Nav link
A styled link for navigation bars, with an active state for the current page.
Selector: a[muiNavLink]
import { NavLink } from '@mushilu-san/ui/navigation';Loading example…
Overview
<a>, so it keeps the link role and keyboard behaviour. Set active for the current page, which adds aria-current="page".
variant to make the link look like plain text or a highlighted primary link, and size to fit the bar.
Guidelines
Do
Mark the current page with active.Keep the list of links short, about five to seven.
Don't
Do not use a nav link for an action such as "Log out". Use a button.
Accessibility
Roles and attributes
| Element | Role | Notes |
|---|---|---|
a[muiNavLink] | link (native) | aria-current="page" when active. |
Keyboard
| Keys | Action |
|---|---|
| TabShiftTab | |
| Enter |
Wrap the links in a <nav>with a label, such as themui-navigation-menudoes.
API
NavLink
| Name | Type | Default | Description |
|---|---|---|---|
variant | 'primary' | 'default' | 'default' | Visual style: `default` for plain text links, `primary` for emphasised links. |
size | 'sm' | 'md' | 'lg' | 'md' | Link text size: `sm`, `md` or `lg`. Default `md`. |
active | boolean | false | Marks the link as the current page with `aria-current="page"`. Accepts attribute presence, e.g. <… active>. |
CSS parts
::part(nav-link)
Tokens
--mui-color-text--mui-color-primary--mui-color-focus-ring--mui-touch-target