Components
Navbar
Built on Base UIThe bar at the top of a site or app. Links fold behind a menu button when it is narrow.
Installation
npx nook-ui@latest add navbarPrompt
Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.
Short. For assistants that can run commands in your project.
Add the Nook "Navbar" component to this project, exactly as Nook ships it.
The bar at the top of a site or app. Links fold behind a menu button when it is narrow.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add navbar`. It writes `components/ui/navbar.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/navbar.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
import { Button } from "@/components/ui/button";
import { Navbar, NavbarActions, NavbarBrand, NavbarLink, NavbarNav, NavbarToggle } from "@/components/ui/navbar";
export default function NavbarDefault() {
return (
<div className="w-full overflow-hidden rounded-lg border border-border">
<Navbar>
<NavbarBrand>
<span aria-hidden="true" className="size-3 bg-brand" />
Nook
</NavbarBrand>
<NavbarNav>
<NavbarLink href="#product" active>Product</NavbarLink>
<NavbarLink href="#pricing">Pricing</NavbarLink>
<NavbarLink href="#docs">Docs</NavbarLink>
<NavbarLink href="#changelog">Changelog</NavbarLink>
</NavbarNav>
<NavbarActions>
<Button size="sm">Sign in</Button>
<NavbarToggle />
</NavbarActions>
</Navbar>
</div>
);
}
```
API
- `Navbar`: The bar. It responds to its own width, not the screen.
- `NavbarBrand, NavbarNav, NavbarActions, NavbarToggle`: The logo, the links, the buttons at the end and the menu button.
- `NavbarMenu`: A link that opens a list of more links. Keyboard: Enter or arrow down opens it, arrows move, Escape closes.
- `label` (`ReactNode`): The text on the button.
- `NavbarMenuLink`: One link inside a menu, with a title, a line of description and an icon.
- `title` (`ReactNode`): The link text.
- `description` (`ReactNode`): What is behind it.
- `icon` (`ReactNode`): An icon before the text.
- `NavbarLink`: One link.
- `active` (`boolean`): Marks the link for the page being viewed.
- `render` (`ReactElement`): Render your router's link instead.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: A header holding a named navigation. The menu button reports `aria-expanded` and is only shown while the links are folded. The current page is marked with `aria-current`.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
import { Button } from "@/components/ui/button";
import { Navbar, NavbarActions, NavbarBrand, NavbarLink, NavbarNav, NavbarToggle } from "@/components/ui/navbar";
export default function NavbarDefault() {
return (
<div className="w-full overflow-hidden rounded-lg border border-border">
<Navbar>
<NavbarBrand>
<span aria-hidden="true" className="size-3 bg-brand" />
Nook
</NavbarBrand>
<NavbarNav>
<NavbarLink href="#product" active>Product</NavbarLink>
<NavbarLink href="#pricing">Pricing</NavbarLink>
<NavbarLink href="#docs">Docs</NavbarLink>
<NavbarLink href="#changelog">Changelog</NavbarLink>
</NavbarNav>
<NavbarActions>
<Button size="sm">Sign in</Button>
<NavbarToggle />
</NavbarActions>
</Navbar>
</div>
);
}Examples
With a menu
A link that opens more links, each with a line of explanation.
Minimal
App header with avatar
Many links
Props
Navbar
The bar. It responds to its own width, not the screen.
NavbarBrand, NavbarNav, NavbarActions, NavbarToggle
The logo, the links, the buttons at the end and the menu button.
NavbarMenu
A link that opens a list of more links. Keyboard: Enter or arrow down opens it, arrows move, Escape closes.
| Prop | Type | Default | Description |
|---|---|---|---|
| label | ReactNode | – | The text on the button. |
NavbarMenuLink
One link inside a menu, with a title, a line of description and an icon.
| Prop | Type | Default | Description |
|---|---|---|---|
| title | ReactNode | – | The link text. |
| description | ReactNode | – | What is behind it. |
| icon | ReactNode | – | An icon before the text. |
NavbarLink
One link.
| Prop | Type | Default | Description |
|---|---|---|---|
| active | boolean | – | Marks the link for the page being viewed. |
| render | ReactElement | – | Render your router's link instead. |
Accessibility
A header holding a named navigation. The menu button reports `aria-expanded` and is only shown while the links are folded. The current page is marked with `aria-current`.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.