Subnav

Defines different styles for a sub navigation.

Usage

To apply this component, use the following classes. To align a subnav, for example to horizontally center it, you can use the Flex component or utility classes from Tailwind CSS.

ClassDescription
.uk-subnavAdd this class to a <ul> element to define the Subnav 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 add list items without a link, use a <span> element instead of an <a>. Alternatively, disable an <a> element by adding the .uk-disabled class to the <li> element and remove the href attribute from the anchor to make it inaccessible through keyboard navigation.

<ul class="uk-subnav">
  <li class="uk-active"><a href=""></a></li>
  <li><a href=""></a></li>
  <li><span></span></li>
</ul>
Copy to clipboard
  • <ul class="uk-subnav" uk-margin>
      <li><a href="#">Active</a></li>
      <li><a href="#">Item</a></li>
      <li><a href="#">Item</a></li>
    </ul>

Style modifiers

Add one of the following classes for additional styles.

ClassDescription
.uk-subnav-primaryAdds a primary style.
.uk-subnav-secondaryAdds a secondary style.
.uk-subnav-dangerAdds a destructive style.
Copy to clipboard
  • <ul class="uk-subnav uk-subnav-primary" uk-margin>
      <li class="uk-active"><a href="#">Active</a></li>
      <li><a href="#">Item</a></li>
      <li><a href="#">Item</a></li>
      <li><span class="opacity-50">Disabled</span></li>
    </ul>
    
    <ul class="uk-subnav uk-subnav-secondary mt-5" uk-margin>
      <li class="uk-active"><a href="#">Active</a></li>
      <li><a href="#">Item</a></li>
      <li><a href="#">Item</a></li>
      <li><span class="opacity-50">Disabled</span></li>
    </ul>
    
    <ul class="uk-subnav uk-subnav-danger mt-5" uk-margin>
      <li class="uk-active"><a href="#">Active</a></li>
      <li><a href="#">Item</a></li>
      <li><a href="#">Item</a></li>
      <li><span class="opacity-50">Disabled</span></li>
    </ul>

You can also use a dropdown from the Dropdown component with a subnav.

<ul class="uk-subnav">
  <li>
    <!-- This is the menu item toggling the dropdown -->
    <a href=""></a>

    <!-- This is the dropdown -->
    <div uk-dropdown="mode: click">
      <ul class="uk-dropdown-nav uk-nav">
        ...
      </ul>
    </div>
  </li>
</ul>
Copy to clipboard
  • <ul class="uk-subnav uk-subnav-primary" uk-margin>
      <li class="uk-active"><a href="#">Active</a></li>
      <li><a href="#">Item</a></li>
      <li>
        <a href>
          <span class="uk-margin-small-right">More</span>
          <uk-icon icon="chevron-down"></uk-icon>
        </a>
        <div uk-dropdown="mode: click">
          <ul class="uk-dropdown-nav uk-nav">
            <li class="uk-active"><a href="#">Active</a></li>
            <li><a href="#">Item</a></li>
            <li class="uk-nav-header">Header</li>
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
            <li class="uk-nav-divider"></li>
            <li><a href="#">Item</a></li>
          </ul>
        </div>
      </li>
    </ul>
Customize