A public site's top bar
import { Button } from "@senvenli/react/action";
import { Text } from "@senvenli/react/display";
import { Navbar } from "@senvenli/react/navigation";
export default function Example() {
return (
<div className="overflow-hidden rounded-ds-large border border-ds-border">
<Navbar
brand="Acme"
brandHref="#"
brandLabel="Acme home"
currentKey="pricing"
links={[
{ id: "features", label: "Features", href: "#" },
{ id: "pricing", label: "Pricing", href: "#" },
{ id: "docs", label: "Docs", href: "#" },
]}
actions={
<>
<Button variant="subtle">Sign in</Button>
<Button variant="primary">Start free trial</Button>
</>
}
/>
<div className="p-ds-300">
<Text tone="subtle">The page starts here.</Text>
</div>
</div>
);
}import {
Navbar,
NavbarBrand,
NavbarItem,
NavbarActions,
} from "@senvenli/react/navigation";Examples
Composed from parts
`NavbarBrand`, `NavbarItem` and `NavbarActions` as children: a logo with an icon, a link with a badge.import { Button } from "@senvenli/react/action";
import { Badge, Icon, Text } from "@senvenli/react/display";
import { Navbar, NavbarActions, NavbarBrand, NavbarItem } from "@senvenli/react/navigation";
export default function Example() {
return (
<div className="overflow-hidden rounded-ds-large border border-ds-border">
<Navbar brandHref="#" brandLabel="Acme home" currentKey="docs">
<NavbarBrand>
<Icon name="hexagon" />
Acme
</NavbarBrand>
<NavbarItem id="features" href="#">
Features
</NavbarItem>
<NavbarItem id="changelog" href="#">
Changelog
<Badge variant="subtle" tone="information">
New
</Badge>
</NavbarItem>
<NavbarItem id="docs" href="#">
Docs
</NavbarItem>
<NavbarActions>
<Button variant="subtle">Sign in</Button>
<Button variant="primary">Start free trial</Button>
</NavbarActions>
</Navbar>
<div className="p-ds-300">
<Text tone="subtle">The page starts here.</Text>
</div>
</div>
);
}Compact, with a language switch
The 48px bar with a LanguageSwitcher among the end actions.import { Button } from "@senvenli/react/action";
import { Navbar } from "@senvenli/react/navigation";
import { LanguageSwitcher } from "@senvenli/react/action";
import { useState } from "react";
// The language switcher is one of the end actions, before the primary action; on phones it moves into the panel.
export default function Example() {
const [locale, setLocale] = useState<"en" | "de" | "fr">("en");
return (
<div className="overflow-hidden rounded-ds-large border border-ds-border">
<Navbar
density="compact"
brand="Acme"
brandHref="#"
brandLabel="Acme home"
links={[
{ id: "features", label: "Features", href: "#" },
{ id: "pricing", label: "Pricing", href: "#" },
]}
actions={
<>
<LanguageSwitcher locales={["en", "de", "fr"]} value={locale} onChange={setLocale} size="small" />
<Button variant="primary" size="small">
Start free trial
</Button>
</>
}
/>
</div>
);
}Guidelines
When to use it
- The main navigation of a marketing or public site.
Use something else when
- An app with many sections. Sidebar
Accessibility
Built in
- A navigation landmark named "Main menu".
- The brand link is named for the home page.
You provide
- A
brandLabelwhen the brand alone does not say where it goes. - With children: an id on every NavbarItem (currentKey matches it), or isCurrent on the page's link.