Cara menggunakan bootstrap 5 navbar template

Documentation and examples for Bootstrap’s powerful, responsive navigation header, the navbar. Includes support for branding, navigation, and more, including support for our collapse plugin.

How it works

Here’s what you need to know before getting started with the navbar:

  • Navbars require a wrapping 4 with 5 for responsive collapsing and classes.
  • Navbars and their contents are fluid by default. Use to limit their horizontal width.
  • Use our spacing and flex utility classes for controlling spacing and alignment within navbars.
  • Navbars are responsive by default, but you can easily modify them to change that. Responsive behavior depends on our Collapse JavaScript plugin.
  • Navbars are hidden by default when printing. Force them to be printed by adding 6 to the 4. See the display utility class.
  • Ensure accessibility by using a element or, if using a more generic element such as a

    , add a 8 to every navbar to explicitly identify it as a landmark region for users of assistive technologies.

Read on for an example and list of supported sub-components.

Supported content

Navbars come with built-in support for a handful of sub-components. Choose from the following as needed:

  • 9 for your company, product, or project name.
  • Bootstrap 0 for a full-height and lightweight navigation (including support for dropdowns).
  • Bootstrap 1 for use with our collapse plugin and other behaviors.
  • Bootstrap 2 for any form controls and actions.
  • Bootstrap 3 for adding vertically centered strings of text.
  • Bootstrap 4 for grouping and hiding navbar contents by a parent breakpoint.

Here’s an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the Bootstrap 5 (large) breakpoint.

Navbar

  • Home (current)
  • Link
  • Dropdown

    Action Another action Something else here

  • Disabled
Search

This example uses color ( Bootstrap 6) and spacing ( Bootstrap 7, Bootstrap 8, Bootstrap 9, Navbar

  • Home (current)
  • Features
  • Pricing
  • Disabled

0) utility classes.

Brand

The 9 can be applied to most elements, but an anchor works best as some elements might require utility classes or custom styles.

Navbar Navbar

Adding images to the 9 will likely always require custom styles or utilities to properly size. Here are some examples to demonstrate.

Bootstrap

Navbar navigation links build on our Navbar

  • Home (current)
  • Features
  • Pricing
  • Disabled

3 options with their own modifier class and require the use of for proper responsive styling. Navigation in navbars will also grow to occupy as much horizontal space as possible to keep your navbar contents securely aligned.

Active states—with Navbar

  • Home (current)
  • Features
  • Pricing
  • Disabled

4—to indicate the current page can be applied directly to Navbar

  • Home (current)
  • Features
  • Pricing
  • Disabled

5s or their immediate parent Navbar

  • Home (current)
  • Features
  • Pricing
  • Disabled

6s.

Navbar

  • Home (current)
  • Features
  • Pricing
  • Disabled

And because we use classes for our navs, you can avoid the list-based approach entirely if you like.

Navbar

Home (current) Features Pricing Disabled

You may also utilize dropdowns in your navbar nav. Dropdown menus require a wrapping element for positioning, so be sure to use separate and nested elements for Navbar

  • Home (current)
  • Features
  • Pricing
  • Disabled

6 and Navbar

  • Home (current)
  • Features
  • Pricing
  • Disabled

5 as shown below.

Navbar

  • Home (current)
  • Features
  • Pricing
  • Dropdown link

    Action Another action Something else here

Forms

Place various form controls and components within a navbar with Bootstrap 2.

Search

Align the contents of your inline forms with utilities as needed.

Navbar Navbar 0

Text

Navbars may contain bits of text with the help of Bootstrap 3. This class adjusts vertical alignment and horizontal spacing for strings of text.

Navbar Navbar 1

Mix and match with other components and utilities as needed.

Navbar Navbar 2

Color schemes

Theming the navbar has never been easier thanks to the combination of theming classes and Navbar

Home (current) Features Pricing Disabled

1 utilities. Choose from Navbar

Home (current) Features Pricing Disabled

2 for use with light background colors, or Navbar

Home (current) Features Pricing Disabled

3 for dark background colors. Then, customize with Navbar

Home (current) Features Pricing Disabled

4 utilities.

Navbar Navbar 3

Containers

Although it’s not required, you can wrap a navbar in a Navbar

Home (current) Features Pricing Disabled

5 to center it on a page or add one within to only center the contents of a .

Navbar Navbar 4

When the container is within your navbar, its horizontal padding is removed at breakpoints lower than your specified 5 class. This ensures we’re not doubling up on padding unnecessarily on lower viewports when your navbar is collapsed.

Navbar Navbar 5

Placement

Use our position utilities to place navbars in non-static positions. Choose from fixed to the top, fixed to the bottom, or stickied to the top (scrolls with the page until it reaches the top, then stays there). Fixed navbars use Navbar

Home (current) Features Pricing Disabled

7, meaning they’re pulled from the normal flow of the DOM and may require custom CSS (e.g., Navbar

Home (current) Features Pricing Disabled

8 on the ) to prevent overlap with other elements.

Also note that Navbar

Home (current) Features Pricing Disabled

9 uses Navbar

  • Home (current)
  • Features
  • Pricing
  • Dropdown link

    Action Another action Something else here

0, which .

Navbar Navbar 6

Navbar Navbar 7

Navbar Navbar 8

Navbar Navbar 9

Responsive behaviors

Navbars can utilize Bootstrap 1, Navbar

  • Home (current)
  • Features
  • Pricing
  • Dropdown link

    Action Another action Something else here

2, and 5 classes to change when their content collapses behind a button. In combination with other utilities, you can easily choose when to show or hide particular elements.

For navbars that never collapse, add the Navbar

  • Home (current)
  • Features
  • Pricing
  • Dropdown link

    Action Another action Something else here

4 class on the navbar. For navbars that always collapse, don’t add any Navbar

  • Home (current)
  • Features
  • Pricing
  • Dropdown link

    Action Another action Something else here

4 class.

Toggler

Navbar togglers are left-aligned by default, but should they follow a sibling element like a 9, they’ll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles.

With no 9 shown in lowest breakpoint:

0

With a brand name shown on the left and toggler on the right:

1

With a toggler on the left and brand name on the right:

2

External content

Sometimes you want to use the collapse plugin to trigger hidden content elsewhere on the page. Because our plugin works on the Navbar

  • Home (current)
  • Features
  • Pricing
  • Dropdown link

    Action Another action Something else here

8 and Navbar

  • Home (current)
  • Features
  • Pricing
  • Dropdown link

    Action Another action Something else here

9 matching, that’s easily done!

Postingan terbaru

LIHAT SEMUA