Navbar
A horizontal navigation bar with multiple styling variants for organizing links and actions. Supports icons, dropdown menus, and consistent visual hierarchy across your application.
Installation
Add Navbar to your project with the CK-UI CLI. It copies the source into your project, so the code is yours to change.
- Adds
Navbar.tsxto your CK-UI folder (src/components/ck-ui by default)- Installs
@radix-ui/react-slotif your project does not have them yet
First time with CK-UI in this project? Run npx ck-ui-cli@latest init once before adding components. The installation guide explains what it sets up.
Manual installationInstall the packages and copy the files yourself.
Install the following dependencies
Run these commands in your terminal to install the required packages
Create or update your Navbar component
Copy this code to create your Navbar component
Test Your Component
- 1. Add the component to a test page
- 2. Check all props and variants work as expected
- 3. Verify responsive behavior
- 4. Test with different content/data
- 5. Ensure accessibility features work correctly
Stroke Variant
Navbar items with border outlines for better visual separation.
Ghost Variant
Minimal styling with hover effects for secondary navigation.
Advanced Examples
Complete navbar examples with logos, icons, and dropdown menus.
API Reference
The Navbar component is a compound component that consists of several parts. Each part has its own set of props that can be used to customize its appearance and behavior.
Navbar.Root
The container component that provides the main navbar structure. Renders a <nav> element.
| Prop | Type | Default | Description |
|---|---|---|---|
className | "string" | "undefined" | Additional CSS classes to apply to the navbar root (a <nav> landmark; pass aria-label when the page has several navigations). |
children | "ReactNode" | "undefined" | The content of the navbar. |
Navbar.Menu
A container for navbar items, typically used to group navigation links.
| Prop | Type | Default | Description |
|---|---|---|---|
className | "string" | "undefined" | Additional CSS classes to apply to the navbar menu. |
children | "ReactNode" | "undefined" | The content of the navbar menu, typically Navbar.Item components. |
Navbar.Item
Individual navigation item that can be styled in different variants and can contain icons.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default""stroke""ghost" | "default" | The visual style variant of the navbar item. |
active | "boolean" | "false" | Marks the current item: applies active styling and sets aria-current ("page" for links, "true" for buttons). |
asChild | "boolean" | "false" | Render the single child element (e.g. a Next.js Link) instead of the default element, merging the item's props, classes and ref onto it. |
href | "string" | "undefined" | Renders the item as a link to this URL. Without href the item is a button (type="button"). |
className | "string" | "undefined" | Additional CSS classes to apply to the navbar item. |
children | "ReactNode" | "undefined" | The content of the navbar item. |
Navbar.Item.Icon
Icon component that can be used within a navbar item.
| Prop | Type | Default | Description |
|---|---|---|---|
as | "ReactElement" | "undefined" | The icon element to render (rendered with aria-hidden; its own className is kept). |
className | "string" | "undefined" | Additional CSS classes to apply to the icon. |