# Sidebar nav
> Sidebar nav with pixel icons and count badges, a hover block and an active bar that slides to the current item.
- React: `import { PxNav } from "@/components/lumesec/px-nav"`
- Collection: Pixel UI (https://elements.lumesec.ai/components/pixel-ui)
- Registry item: https://elements.lumesec.ai/r/px-nav.json
- Page: https://elements.lumesec.ai/components/pixel-ui/nav



Live preview: https://elements.lumesec.ai/view/px-nav

Demo source:

```tsx
import { PxNav } from "@/components/lumesec/px-nav";

export default function PxNavDemo() {
  return (
    <div className="w-full max-w-[400px] rounded-[14px] border border-border bg-card px-5 py-[18px] shadow-[0_14px_34px_-20px_rgb(0_0_0/0.4)]">
      <PxNav
        items={[
          { href: "#home", label: "Home", icon: "home" },
          { href: "#chats", label: "Chats", icon: "chat", badge: "3" },
          { href: "#projects", label: "Projects", icon: "folder" },
          { href: "#usage", label: "Usage", icon: "chart" },
          { href: "#team", label: "Team", icon: "users" },
          { href: "#settings", label: "Settings", icon: "gear" },
        ]}
      />
    </div>
  );
}
```

## Playground

Change a prop and the component re-renders. Props marked remounts set an initial value, so the component starts over.

## Installation

```bash
npx shadcn@latest add @lumesec/px-nav
```

First time with the @lumesec registry? Register it once, or install by URL:

```bash
npx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.json
npx shadcn@latest add https://elements.lumesec.ai/r/px-nav.json
```

## Usage

React:

```tsx
import { PxNav } from "@/components/lumesec/px-nav";

export function Example() {
  return (
    <PxNav
      aria-label="Main"
      items={[
        { href: "#home", label: "Home", icon: "home" },
        { href: "#chats", label: "Chats", icon: "chat", badge: "3" },
        { href: "#settings", label: "Settings", icon: "gear" },
      ]}
    />
  );
}
```

## Behaviour

Takes a list of links and adds pixel icons, count badges, a soft hover block and an active bar that slides to the current item.

## API reference

### Props

Also accepts every prop of `<nav>` (`React.ComponentProps<"nav">`), spread onto the root element.

| Prop            | Type                      | Default      | Description                                                                                                                 |
| --------------- | ------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------- |
| `value`         | `string`                  | —            | Controlled `href` of the current item. Use with `onValueChange`.                                                            |
| `defaultValue`  | `string`                  | `first item` | `href` of the initially current item when uncontrolled.                                                                     |
| `items`         | `readonly PxNavItem[]`    | —            | The links: `{ href: string; label: string; icon?: PxNavIcon; badge?: string }`. `href` also identifies the item in `value`. |
| `onValueChange` | `(value: string) => void` | —            | Called with the `href` of a link the user clicks, when it is not already current.                                           |

### Ref

`ref` points at the root `HTMLElement`.

## Accessibility

* Links are native `<a>` elements inside a `<nav>`; pass `aria-label` to name the nav.
* The current link has `aria-current="page"`.
* Icons are drawn on an `aria-hidden` canvas. A badge is text inside its link, so assistive technology reads it as part of the link's name.
* Focusing a link shows the same hover block as the pointer.
* Reduced motion: the active bar and the hover block jump instead of springing.

## Theming

Styled with Tailwind classes on your shadcn theme tokens, so light and dark follow your theme. The accent comes from `--lumesec`. See [Theming](/docs/theming).

This component reads `--lumesec`, `--foreground`, `--muted-foreground`, `--destructive` and `--lumesec-foreground`.

## Notes

* `icon` picks a built-in icon: `home`, `chat`, `folder`, `chart`, `gear`, `users` or `bell`. `badge` shows a small badge with that text at the end of the row, in the mono font: red, or accent on the current item.
* Clicking a link whose `href` starts with `#` does not navigate; other links navigate as usual after being marked current. To route on the client, handle `onValueChange` or replace the `<a>` with your router's link.


