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.
Class | Description |
---|---|
.uk-subnav | Add 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.
Class | Description |
---|---|
.uk-subnav-primary | Adds a primary style. |
.uk-subnav-secondary | Adds a secondary style. |
.uk-subnav-danger | Adds 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>
Subnav and Dropdown
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>
- On This Page
- Usage
- Style modifiers
- Subnav and Dropdown
Request Web Components
Franken UI is an independent project. Help support it and
expand its free component library.
Reach out