The primary navigation component is a complete header menu system. It's made up of four preassigned areas: logo, main menu, search, and actions. The main menu container includes an optional search field.
There are two distinct placements available for the main menu. The first menu placement is inline with the logo, creating a slim navigation bar:
The second menu placement is below the logo, spanning the full width of the component:
Both menus use the same HTML markup but include a different modifier on their parent selector.
The .primary-nav--inline--{x} places the menu inline with the logo. In contrast, .primary-nav--below--{x} selector places the menu below the logo. Here, x equals its breakpoint modifier (e.g., lg for large). At this point the component changes layout from mobile to desktop.
Figure 1 (below) provides the entire HTML for the primary navigation component.
When using a single color svg for the logo, the data-logo="brand" attribute placed on the <a> tag sets the svg fill color to currentColor. This is useful when a theme color utility is present on a parent element.
It contains the website's menu and search buttons (on mobile viewports).
The search toggle button is only required within the .primary-nav--inline--{x} selector. This is because with .primary-nav--below--{x}, the .primary-nav__search selector (described below) remains visible from mobile to dektop.
The data-target-toggle attribute equals the value of the main menu's id attribute.
The aria-label="Toggle Menu" attribute provides a descriptive name for assistive technology.
Add the .nav--divider modifier class to a .nav selector for a vertical, bordered navigation (Figure 7).
Include the aformentioned .nav--horizontal and .nav--horizontal--{bp} modifier classes to .nav-divider selectors. This produces a horizontal (and responsive) bordered menu (Figure 8).
Icons in Navigation
Generic navigation can include icons. Add the .nav--has-icons modifier class to a .nav selector. Nav items with icons (<a> or <button>) require two child selectors.
The first child is is a <span> with its combined icon classes. The second child is a <span> with a .nav__text class. This holds the nav items's text. Further, the .nav__text selector is our target for underlining the text on :hover and :focus states. It also provides a small margin to separate the text from the icon. See Figure 9.
Dropdown Items
Include dropdown items within .nav, and .nav--divider selectors. As well as within the .primary-nav__menu selector inside the primary navigation component.
To create a dropdown, include the data-toggle="dropdown" attribute on a <button> (Figure 8, line 3). Add a sibling <ul> with the .nav__dropdown class (Figure 10, line 4).
Dropdowns work as you might expect within vertical navigation:
Related CSS Variables
Further customize Navigation by redefining any of their related CSS variables as shown below.