Nav

Defines different styles for list navigations.

Table of contents

Usage

To apply this component, use the following classes.

ClassDescription
.uk-navAdd this class to a <ul> element to define the Nav component. Use <a> elements as nav items within the list.
.uk-active Add this class to a list item to apply an active state to a menu item.

Note By default, the nav has no styling. That’s why it is important to add a modifier class. In our example we are using the .uk-nav-default class.

Nested navs

Add the .uk-parent class to an item to turn it into a parent. Add the .uk-nav-sub class to a <ul> element inside the item to create the subnav.

Accordion

By default, child menu items are always visible. To apply an accordion effect, just add the data-uk-nav attribute to the main <ul>.

Note The attribute automatically sets the .uk-nav class, so you don’t have to apply it manually.

Parent icon

To create a parent icon, just add the data-uk-nav-parent-icon attribute to a <span> element.

Multiple open subnavs

When clicking on a parent item, an open one will close, allowing only one open nested list at a time. To allow multiple open subnavs, just add the multiple: true option to the attribute.

Header and divider

Add one of the following classes to a list item to create a header or a divider between items.

ElementDescription
.uk-nav-headerAdd this class to a <li> element to create a header.
.uk-nav-dividerAdd this class to a <li> element to create a divider separating nav items.

Subtitle

Add the .uk-nav-subtitle class to a div element to create an item subtitled.

Default modifier

Add the .uk-nav-default class to give the nav its default style. You can place the nav inside cards or anywhere else in your content.

Primary modifier

Add the .uk-nav-primary class to give the nav a more distinct styling, for example when placing it inside a modal.

Secondary modifier

Add the .uk-nav-secondary class to have an extra style if the nav has subtitles.

Add the .uk-dropdown-nav class to place a nav inside a default dropdown from the Dropdown component.

A nav can be used inside an offcanvas from the Offcanvas component. No modifier class needs to be added.

Component options

Any of these options can be applied to the component attribute. Separate multiple options with a semicolon. Learn more

OptionValueDefaultDescription
targetsCSS selector> .uk-parentThe element(s) to toggle.
toggle CSS selector> aThe toggle element(s).
contentCSS selector> ulThe content element(s).
collapsibleBooleantrueAllow all items to be closed.
multipleBooleanfalseAllow multiple open items.
transitionStringeaseThe transition to use.
animationBoolean, StringtrueSpace-separated names of animations. Comma-separated for animation out.
durationNumber200The animation duration in milliseconds.

JavaScript

Learn more about JavaScript components.

Initialization

Methods

The following methods are available for the component:

Toggle

Toggles the content pane.

NameTypeDefaultDescription
indexString, Number, Node0Nav pane to toggle. 0 based index.
animateBooleantrueSuppress opening animation by passing false.
Customize

Customize your Franken UI experience.