Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Navigation

Nav link

A styled link for navigation bars, with an active state for the current page.

Selector: a[muiNavLink]

Import
import { NavLink } from '@mushilu-san/ui/navigation';
PreviewCode

Loading example…

Overview

Nav link is applied to a native <a>, so it keeps the link role and keyboard behaviour. Set active for the current page, which adds aria-current="page".

Use variant to make the link look like plain text or a highlighted primary link, and size to fit the bar.

When to use

  • Links in a top bar or footer that should look like navigation.
  • Showing which section of the site is open.

When not to use

  • A call to action that performs an action. Use a Button. Use Button instead.

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

ElementRoleNotes
a[muiNavLink]link (native)aria-current="page" when active.

Keyboard

KeysAction
TabShiftTabMoves focus between the links.
EnterFollows the link.
  • Wrap the links in a <nav> with a label, such as the mui-navigation-menu does.

API

Selector: a[muiNavLink]

NameTypeDefaultDescription
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`.
activebooleanfalse 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