Navbar, simple
betaThe product's name, up to six links and two actions; below a narrow width, the links fold into a sheet.
npx rasengan-ui add navbar-simple
- Use it
- At the top of a landing page with a handful of sections and one main action.
- Avoid it
- More than six links, or menus with sub-pages: use the Navigation Menu component.
- Pairs with
- Hero, centred
Installation
It installs into components/blocks/navbar-simple/, with what it uses (Button, Sheet) and lib/blocks.ts.
Usage
Without content, the block shows its example. Pass your own, typed by the block's schema, from a content file (here, the example with one field changed):
Make it stick to the top with className="sticky top-0 z-40".
Content
| Field | Type | Limits | Guidance |
|---|---|---|---|
brand | object | ||
brand.name | string | 1–32 chars | The product's name, shown next to the logo, or alone. |
brand.href | string | Where the name leads: usually '/'. | |
brand.logooptional | object | A square mark, about 32px; decorative next to the name, so its alt may be empty. | |
brand.logo.src | string | A local path ('/images/terrace.jpg') or the project's asset URL. | |
brand.logo.alt | string | ≤ 140 chars | What the image shows, for people who cannot see it. Empty only if purely decorative. |
brand.logo.width | integer | ||
brand.logo.height | integer | ||
links | object[] | 1–6 items | The page's main sections or pages, in reading order. |
links[].label | string | 1–24 chars | One or two words: 'Pricing', 'Docs'. |
links[].href | string | A path or an anchor on the page: '/pricing', '#features'. | |
menuLabel | string | 1–24 chars | The name of the menu button on narrow screens: 'Menu'. |
secondaryoptional | object | A quiet action before the main one: 'Sign in'. | |
secondary.label | string | 1–32 chars | A verb first, two to four words: 'Start free', 'Book a table'. |
secondary.href | string | A path ('/pricing'), an anchor ('#menu'), or a full URL. | |
primary | object | The one action the page is for: 'Start free'. | |
primary.label | string | 1–32 chars | A verb first, two to four words: 'Start free', 'Book a table'. |
primary.href | string | A path ('/pricing'), an anchor ('#menu'), or a full URL. |
Props
| Prop | Notes |
|---|---|
content | NavbarSimpleContent; the example when left out |
id | the header's id, for anchor links; "top" by default |
className | on the root element, for spacing |
Accessibility
- A
<header>with a<nav>named by the product's name; the menu button is named bymenuLabel. - Below
@3xlthe links move into a Sheet: focus goes into it and comes back to the button when it closes. - It has no heading, so
headingLeveldoes nothing.