Skip to content

Navbar - Flowbite Vue ​


Navbar - Flowbite

Original reference: https://flowbite.com/docs/components/navbar/

The navbar component can be used to create a responsive navigation bar at the top of your page with support for a logo, navigation links, a collapsible mobile menu, and an optional call-to-action button.

Default Navbar ​

Use FwbNavbar as the outer shell, FwbNavbarLogo in the logo slot, and FwbNavbarLink components inside FwbNavbarCollapse in the default slot. The default slot exposes isShowMenu to wire up the collapse visibility.

vue
<template>
  <fwb-navbar>
    <template #logo>
      <fwb-navbar-logo alt="Flowbite logo" image-url="/images/logo.svg" link="#">
        Flowbite
      </fwb-navbar-logo>
    </template>
    <template #default="{isShowMenu}">
      <fwb-navbar-collapse :is-show-menu="isShowMenu">
        <fwb-navbar-link is-active link="#">
          Home
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Services
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Pricing
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Contact
        </fwb-navbar-link>
      </fwb-navbar-collapse>
    </template>
  </fwb-navbar>
</template>

<script setup>
import {
  FwbNavbar,
  FwbNavbarCollapse,
  FwbNavbarLink,
  FwbNavbarLogo,
} from 'flowbite-vue'
</script>

Solid Navbar ​

Add the solid prop to switch from the default white navbar to a solid gray background with a dark mode variant.

vue
<template>
  <fwb-navbar solid>
    <template #logo>
      <fwb-navbar-logo alt="Flowbite logo" image-url="/images/logo.svg" link="#">
        Flowbite
      </fwb-navbar-logo>
    </template>
    <template #default="{isShowMenu}">
      <fwb-navbar-collapse :is-show-menu="isShowMenu">
        <fwb-navbar-link is-active link="#">
          Home
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Services
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Pricing
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Contact
        </fwb-navbar-link>
      </fwb-navbar-collapse>
    </template>
  </fwb-navbar>
</template>

<script setup>
import {
  FwbNavbar,
  FwbNavbarCollapse,
  FwbNavbarLink,
  FwbNavbarLogo,
} from 'flowbite-vue'
</script>

Use the right-side slot to place a button or any other element on the right side of the navbar, shown alongside the links on desktop and hidden on mobile.

vue
<template>
  <fwb-navbar>
    <template #logo>
      <fwb-navbar-logo alt="Flowbite logo" image-url="/images/logo.svg" link="#">
        Flowbite
      </fwb-navbar-logo>
    </template>
    <template #default="{isShowMenu}">
      <fwb-navbar-collapse :is-show-menu="isShowMenu">
        <fwb-navbar-link is-active link="#">
          Home
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Services
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Pricing
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Contact
        </fwb-navbar-link>
      </fwb-navbar-collapse>
    </template>
    <template #right-side>
      <fwb-button>
        Get started
      </fwb-button>
    </template>
  </fwb-navbar>
</template>

<script setup>
import {
  FwbButton,
  FwbNavbar,
  FwbNavbarCollapse,
  FwbNavbarLink,
  FwbNavbarLogo,
} from 'flowbite-vue'
</script>

Use the menu-icon slot to replace the default hamburger icon on the mobile toggle button with any SVG or custom element.

vue
<template>
  <fwb-navbar>
    <template #logo>
      <fwb-navbar-logo alt="Flowbite logo" image-url="/images/logo.svg" link="#">
        Flowbite
      </fwb-navbar-logo>
    </template>
    <template #default="{isShowMenu}">
      <fwb-navbar-collapse :is-show-menu="isShowMenu">
        <fwb-navbar-link is-active link="#">
          Home
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Services
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Pricing
        </fwb-navbar-link>
        <fwb-navbar-link link="#">
          Contact
        </fwb-navbar-link>
      </fwb-navbar-collapse>
    </template>
    <template #menu-icon>
      <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
        <path d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
      </svg>
    </template>
  </fwb-navbar>
</template>

<script setup>
import {
  FwbNavbar,
  FwbNavbarCollapse,
  FwbNavbarLink,
  FwbNavbarLogo,
} from 'flowbite-vue'
</script>

FwbNavbar Props ​

NameTypeDefaultDescription
classString''Additional classes applied to the <nav> element.
roundedBooleanfalseAdds a rounded style to the navbar container.
solidBooleanfalseApplies a solid gray background instead of white.
stickyBooleanfalseFixes the navbar to the top of the viewport.

FwbNavbar Slots ​

NameDescription
defaultNavigation content. Exposes { isShowMenu: boolean } for wiring up the collapse.
logoBrand logo area, typically a FwbNavbarLogo component.
menu-iconReplaces the default hamburger SVG in the mobile toggle button.
right-sideContent rendered to the right of the nav links on desktop (e.g. a CTA button).

FwbNavbarCollapse Props ​

NameTypeDefaultDescription
isShowMenuBooleanfalseControls whether the mobile menu is expanded. Pass from FwbNavbar's isShowMenu slot prop.

FwbNavbarCollapse Slots ​

NameDescription
defaultOne or more FwbNavbarLink elements.
NameTypeDefaultDescription
componentString'a'Root element tag or component name (e.g. 'router-link').
disabledBooleanfalseSuppresses the click event when set.
isActiveBooleanfalseHighlights the link as the current page.
linkString'/'The URL or route passed to the link element.
linkAttrString'href'Attribute name used to pass link (e.g. 'to' for router-link).
NameDescription
clickEmitted when the link item is clicked.
NameDescription
defaultThe link label text.

FwbNavbarLogo Props ​

NameTypeDefaultDescription
altString'Logo'Alt text for the logo image.
componentString'a'Root element tag or component name.
imageUrlString'/assets/logo.svg'URL of the logo image.
linkString'/'The URL or route passed to the logo link.
linkAttrString'href'Attribute name used to pass link (e.g. 'to' for router-link).

FwbNavbarLogo Slots ​

NameDescription
defaultBrand name text displayed next to the logo.

Released under the MIT License.