# Navbar Navigation bar component for creating responsive headers with logo, navigation links, and actions. ## Tag `Navbar` ## Props | Prop | Type | Default | Description | | :--- | :--- | :--- | :--- | | `class` | `string` | `''` | Additional CSS classes (DaisyUI + Tailwind) | | `children` | `VNode \| Array` | `-` | Navbar content (should contain left, center, right sections) | ## Styling Navbar supports all **daisyUI Navbar classes**: | Category | Keywords | Description | | :--- | :--- | :--- | | Base | `navbar` | Base navbar styling | | Sections | `navbar-start`, `navbar-center`, `navbar-end` | Content alignment sections | | Background | `bg-base-100`, `bg-base-200`, `bg-primary`, etc. | Background colors | | Shadow | `shadow`, `shadow-lg`, `shadow-md` | Box shadow variants | > For further details, check the [daisyUI Navbar Documentation](https://daisyui.com/components/navbar) – Full reference for CSS classes. ## Live Examples ### Basic Navbar

Live Demo

```javascript const BasicDemo = () => { return Navbar({ class: 'rounded-box' }, [ Div({ class: 'navbar-start' }, [ Span({ class: 'text-xl font-bold' }, 'Logo') ]), Div({ class: 'navbar-center hidden lg:flex' }, [ Span({ class: 'text-sm' }, 'Navigation Items') ]), Div({ class: 'navbar-end' }, [ Button({ class: 'btn btn-ghost btn-sm' }, 'Login') ]) ]); }; $mount(BasicDemo, '#demo-basic'); ``` ### With Navigation Links

Live Demo

```javascript const LinksDemo = () => { const active = $('home'); return Navbar({ class: 'rounded-box' }, [ Div({ class: 'navbar-start' }, [ Span({ class: 'text-xl font-bold' }, 'MyApp') ]), Div({ class: 'navbar-center hidden lg:flex' }, [ Div({ class: 'menu menu-horizontal px-1' }, [ Button({ class: `btn btn-ghost btn-sm ${active() === 'home' ? 'btn-active' : ''}`, onclick: () => active('home') }, 'Home'), Button({ class: `btn btn-ghost btn-sm ${active() === 'about' ? 'btn-active' : ''}`, onclick: () => active('about') }, 'About'), Button({ class: `btn btn-ghost btn-sm ${active() === 'contact' ? 'btn-active' : ''}`, onclick: () => active('contact') }, 'Contact') ]) ]), Div({ class: 'navbar-end' }, [ Button({ class: 'btn btn-primary btn-sm' }, 'Sign Up') ]) ]); }; $mount(LinksDemo, '#demo-links'); ``` ### With Search

Live Demo

```javascript const SearchDemo = () => { const searchQuery = $(''); return Navbar({ class: 'rounded-box' }, [ Div({ class: 'navbar-start' }, [ Span({ class: 'text-xl font-bold' }, 'MyApp') ]), Div({ class: 'navbar-center' }, [ Div({ class: 'form-control' }, [ Input({ placeholder: 'Search...', value: searchQuery, class: 'input input-bordered w-48 md:w-auto', oninput: (e) => searchQuery(e.target.value) }) ]) ]), Div({ class: 'navbar-end' }, [ Button({ class: 'btn btn-ghost btn-circle' }, '🔔'), Button({ class: 'btn btn-ghost btn-circle' }, '👤') ]) ]); }; $mount(SearchDemo, '#demo-search'); ``` ### With Avatar and Dropdown

Live Demo

```javascript const AvatarDemo = () => { return Navbar({ class: 'rounded-box' }, [ Div({ class: 'navbar-start' }, [ Span({ class: 'text-xl font-bold' }, 'MyApp') ]), Div({ class: 'navbar-center hidden lg:flex' }, [ Div({ class: 'menu menu-horizontal px-1' }, [ Span({ class: 'text-sm' }, 'Dashboard'), Span({ class: 'text-sm' }, 'Projects'), Span({ class: 'text-sm' }, 'Tasks') ]) ]), Div({ class: 'navbar-end' }, [ Div({ class: 'dropdown dropdown-end' }, [ Div({ tabindex: 0, role: 'button', class: 'btn btn-ghost btn-circle avatar' }, [ Div({ class: 'w-8 rounded-full bg-primary text-primary-content flex items-center justify-center' }, 'JD') ]), Div({ tabindex: 0, class: 'dropdown-content menu bg-base-100 rounded-box z-[1] w-52 p-2 shadow' }, [ Span({ class: 'menu-item' }, 'Profile'), Span({ class: 'menu-item' }, 'Settings'), Span({ class: 'menu-item' }, 'Logout') ]) ]) ]) ]); }; $mount(AvatarDemo, '#demo-avatar'); ``` ### Responsive Navbar

Live Demo

```javascript const ResponsiveDemo = () => { const isOpen = $(false); return Div({ class: 'flex flex-col' }, [ Navbar({ class: 'rounded-box' }, [ Div({ class: 'navbar-start' }, [ Button({ class: 'btn btn-ghost btn-circle lg:hidden', onclick: () => isOpen(!isOpen()) }, '☰') ]), Div({ class: 'navbar-center' }, [ Span({ class: 'text-xl font-bold' }, 'MyApp') ]), Div({ class: 'navbar-end' }, [ Button({ class: 'btn btn-ghost btn-circle' }, '🔔') ]) ]), () => isOpen() ? Div({ class: 'flex flex-col gap-2 p-4 bg-base-200 rounded-box mt-2' }, [ Button({ class: 'btn btn-ghost justify-start' }, 'Home'), Button({ class: 'btn btn-ghost justify-start' }, 'About'), Button({ class: 'btn btn-ghost justify-start' }, 'Services'), Button({ class: 'btn btn-ghost justify-start' }, 'Contact') ]) : null ]); }; $mount(ResponsiveDemo, '#demo-responsive'); ``` ### With Brand and Actions

Live Demo

```javascript const BrandDemo = () => { return Navbar({ class: 'rounded-box bg-primary text-primary-content' }, [ Div({ class: 'navbar-start' }, [ Span({ class: 'text-xl font-bold' }, 'Brand') ]), Div({ class: 'navbar-center hidden lg:flex' }, [ Div({ class: 'menu menu-horizontal px-1' }, [ Span({ class: 'text-sm' }, 'Features'), Span({ class: 'text-sm' }, 'Pricing'), Span({ class: 'text-sm' }, 'About') ]) ]), Div({ class: 'navbar-end' }, [ Button({ class: 'btn btn-ghost btn-sm' }, 'Login'), Button({ class: 'btn btn-outline btn-sm ml-2' }, 'Sign Up') ]) ]); }; $mount(BrandDemo, '#demo-brand'); ``` ### All Variants

Live Demo

```javascript const VariantsDemo = () => { return Div({ class: 'flex flex-col gap-4' }, [ Div({ class: 'text-sm font-bold' }, 'Default Navbar'), Navbar({ class: 'rounded-box' }, [ Div({ class: 'navbar-start' }, [Span({}, 'Start')]), Div({ class: 'navbar-center' }, [Span({}, 'Center')]), Div({ class: 'navbar-end' }, [Span({}, 'End')]) ]), Div({ class: 'text-sm font-bold mt-2' }, 'With Shadow'), Navbar({ class: 'rounded-box shadow-lg' }, [ Div({ class: 'navbar-start' }, [Span({}, 'Logo')]), Div({ class: 'navbar-end' }, [Button({ class: 'btn btn-sm' }, 'Button')]) ]), Div({ class: 'text-sm font-bold mt-2' }, 'With Background'), Navbar({ class: 'rounded-box bg-base-300' }, [ Div({ class: 'navbar-start' }, [Span({ class: 'font-bold' }, 'Colored')]), Div({ class: 'navbar-end' }, [Span({ class: 'text-sm' }, 'Info')]) ]) ]); }; $mount(VariantsDemo, '#demo-variants'); ```