Navbar
A horizontal navigation bar component with flexible left and right sections for building site headers and navigation.1<Navbar>2 <Navbar.Start>3 <Text size="regular" weight="medium">4 Explore5 </Text>6 </Navbar.Start>7 <Navbar.End>8 <Search9 placeholder="Search an AOI"10 size="small"11 style={{ width: "200px" }}12 />13 <Button14 variant="outline"15 size="small"16 color="neutral"17 leadingIcon={<FilterIcon />}18 >19 Draw AOI20 </Button>21 <Button22 variant="outline"23 size="small"24 color="neutral"25 leadingIcon={<OrganizationIcon />}26 >
Usage
1import { Navbar } from "@raystack/apsara";
Component Structure
The Navbar component uses a composite pattern, providing modular sub-components for flexible navigation layouts:
Navbar- Root container that wraps the navigation barNavbar.Start- Left section container for brand, logo, or primary navigationNavbar.End- Right section container for actions, search, or secondary navigation
Navbar Props
Prop
Type
Navbar.Start Props
The start section is a container component that accepts all div props. It's commonly used for brand logos, primary navigation links, or page titles.
Prop
Type
Navbar.End Props
The end section is a container component that accepts all div props. It's commonly used for search inputs, action buttons, user menus, or secondary navigation.
Prop
Type
Examples
Sticky Navigation
The Navbar can be made sticky to remain visible at the top of the viewport when scrolling.
1<Navbar>2 <Navbar.Start>3 <Text size="regular" weight="medium">4 Navigation5 </Text>6 </Navbar.Start>7 <Navbar.End>8 <Button variant="ghost" size="small">9 Home10 </Button>11 <Button variant="ghost" size="small">12 About13 </Button>14 <Button variant="ghost" size="small">15 Contact16 </Button>17 </Navbar.End>18</Navbar>
Section Layouts
You can use either or both sections depending on your needs. The sections automatically position themselves with proper spacing.
1<Navbar>2 <Navbar.Start>3 <Text size="regular" weight="medium">4 Brand Name5 </Text>6 </Navbar.Start>7</Navbar>
Accessibility
The Navbar supports custom ARIA labels for better screen reader support. You can provide descriptive labels for the entire navbar or individual sections.
1<Navbar aria-label="Primary navigation">2 <Navbar.Start>3 <Text size="regular" weight="medium">4 Brand5 </Text>6 </Navbar.Start>7 <Navbar.End>8 <Button size="small">Menu</Button>9 </Navbar.End>10</Navbar>
Accessibility
The Navbar implements the following accessibility features:
-
Proper ARIA roles and attributes
role="navigation"for the main navbarrole="group"for Start and End sections whenaria-labelis provided- Customizable
aria-labelandaria-labelledbysupport
-
Semantic HTML
- Uses
<nav>element for proper navigation landmark - Maintains proper heading hierarchy when using
aria-labelledby
- Uses
-
Screen reader support
- Meaningful labels for all sections
- Clear structure for assistive technologies
- Support for linking to visible headings via
aria-labelledby