Switcher

Dynamically transition through different content panes.

Usage

The switcher component consists of a number of toggles and their related content items. Add the data-uk-switcher="{connect:'#ID'}" attribute to the element which contains the toggles, targetting the same id as is used on the element containing the content items. Add the .uk-switcher class to the same element. Typically the switcher is combined with other components, some of which will be shown here.

Example

Markup

<!-- This is the container of the toggling elements -->
<ul data-uk-switcher="{connect:'#my-id'}">
    <li><a href="">...</a></li>
</ul>

<!-- This is the container of the content items -->
<ul id="my-id" class="uk-switcher">
    <li>...</li>
</ul>

Switch items from within content

In some cases you want to switch to another content section from within the active content. This is possible using the data-uk-switcher-item attribute. To target the items, you need to set the data attribute to the number of the respective content item.

Example

Markup

<!-- This is the nav containing the toggling elements -->
<ul data-uk-switcher="{connect:'#my-id'}">
    <li><a href="">...</a></li>
</ul>

<!-- This is the container of the content items -->
<ul id="my-id" class="uk-switcher">
    <li> ... <a href="" data-uk-switcher-item="0">...</a></li>
    <li> ... <a href="" data-uk-switcher-item="1">...</a></li>
</ul>

Setting the attribute to next and previous will switch to the adjacent items.

Markup

<li> ... <a href="" data-uk-switcher-item="next">...</a></li>
<li> ... <a href="" data-uk-switcher-item="previous">...</a></li>

Connect multiple items

It is also possible to connect multiple content containers. Just extend the connect parameter with the ID of the additional container.

Example

Container 1

  • Hello from container 1!
  • Hello again from container 1!
  • Bazinga from container 1!

Container 2

  • Hello from container 2!
  • Hello again from container 2!
  • Bazinga from container 2!

Markup

<!-- This is the nav containing the toggling elements -->
<ul data-uk-switcher="{connect:'#my-id-one, #my-id-two'}">
    <li><a href="">...</a></li>
</ul>

<!-- These are the containers of the content items -->
<ul id="my-id-one" class="uk-switcher">
    <li>...</li>
</ul>

<ul id="my-id-two" class="uk-switcher">
    <li>...</li>
</ul>

Animations

The Switcher component allows you to add different animations to items when toggling between them. All you need to do is add the animation parameter to the data-attribute and define the animation that you want to apply. Check the table below for an overview of the animations provided.

Class Description
fade The element fades in.
scale The items scale up.
slide-top The items slide in from the top.
slide-bottom The items slide in from the bottom.
slide-left The items slide in from the left.
slide-right The items slide in from the right.
slide-horizontal The items slide horizontally, the direction depending on the adjacency of the item.
slide-vertical The items slide vertically, the direction depending on the adjacency of the item.

Example

Fade
  • Hello!
  • Hello again!
  • Bazinga!
Scale
  • Hello!
  • Hello again!
  • Bazinga!
Slide top
  • Hello!
  • Hello again!
  • Bazinga!
Slide bottom
  • Hello!
  • Hello again!
  • Bazinga!
Slide left
  • Hello!
  • Hello again!
  • Bazinga!
Slide right
  • Hello!
  • Hello again!
  • Bazinga!
Slide horizontal
  • Hello!
  • Hello again!
  • Bazinga!
Slide vertical
  • Hello!
  • Hello again!
  • Bazinga!

Markup

<!-- This is the container of the toggling elements -->
<ul data-uk-switcher="{connect:'#my-id', animation: 'fade'}">
    <li><a href="">...</a></li>
</ul>

<!-- This is the container of the content items -->
<ul id="my-id" class="uk-switcher">
    <li>...</li>
</ul>

Custom animations

You can also apply multiple animations by using the uk-animation-* classes from the Animation component. That way you can even create your own custom class to apply a different transition to the switcher.

Example

  • Hello!
  • Hello again!
  • Bazinga!

Markup

<!-- This is the container of the toggling elements -->
<ul data-uk-switcher="{connect:'#my-id', animation: 'uk-animation-fade, uk-animation-slide-left'}">
    <li><a href="">...</a></li>
</ul>

<!-- This is the container of the content items -->
<ul id="my-id" class="uk-switcher">
    <li>...</li>
</ul>

Switcher with subnav

The switcher is easily applied to the Subnav component.

Example

Markup

<!-- This is the subnav containing the toggling elements -->
<ul class="uk-subnav uk-subnav-pill" data-uk-switcher="{connect:'#my-id'}">
    <li><a href="">...</a></li>
</ul>

<!-- This is the container of the content items -->
<ul id="my-id" class="uk-switcher">
    <li>...</li>
</ul>

Switcher with tabs

As an exception to the rule, add the data-uk-tab="{connect:'#ID'}" attribute, using the parameter "tab" instead of "switcher", to the tabbed navigation to combine the switcher with the Tab component.

Example

  • Hello!
  • Hello again!
  • Bazinga!
  • Hello!
  • Hello again!
  • Bazinga!

Markup

<!-- This is the tabbed navigation containing the toggling elements -->
<ul class="uk-tab" data-uk-tab="{connect:'#my-id'}">
    <li><a href="">...</a></li>
</ul>

<!-- This is the container of the content items -->
<ul id="my-id" class="uk-switcher uk-margin">
    <li>...</li>
</ul>

NOTE When using the tab bottom modifier, navigation and content need to be arranged in reversed order, so that the content appears above the tabs.


Vertical tab

Use the Grid component to display content correctly with a vertical tabbed navigation.

Example

  • Hello!
  • Hello again!
  • Bazinga!
  • Hello!
  • Hello again!
  • Bazinga!

Example

<!-- This is the left vertical tabbed navigation -->
<div class="uk-grid">
    <div class="uk-width-medium-1-2">
        <!-- This is the vertical tabbed navigation containing the toggling elements -->
        <ul class="uk-tab uk-tab-left" data-uk-tab="{connect:'#my-id'}">...</ul>
    </div>
    <div class="uk-width-medium-1-2">
        <!-- This is the container of the content items -->
        <ul id="my-id" class="uk-switcher">...</ul>
    </div>
</div>

<!-- This is the right vertical tabbed navigation -->
<div class="uk-grid">
    <div class="uk-width-medium-1-2 uk-push-1-2">
        <!-- This is the vertical tabbed navigation containing the toggling elements -->
        <ul class="uk-tab uk-tab-right" data-uk-tab="{connect:'#my-id'}">...</ul>
    </div>
    <div class="uk-width-medium-1-2 uk-pull-1-2">
        <!-- This is the container of the content items -->
        <ul id="my-id" class="uk-switcher">...</ul>
    </div>
</div>

Switcher with buttons

The switcher can also be applied to buttons or button groups from the Button component. Just add the switcher data attribute to a <div> element around a group of buttons or to the element with the .button-group class.

Example

Link
  • Hello!
  • Hello again!
  • Bazinga!
Link
  • Hello!
  • Hello again!
  • Bazinga!

Markup

<!-- This is the container of the toggling buttons -->
<div data-uk-switcher="{connect:'#my-id'}">
    <button class="uk-button" type="button">...</button>
</div>

<!-- This is the container of the content items -->
<ul id="my-id" class="uk-switcher uk-margin">...</ul>

<!-- This is the button group containing the toggling buttons -->
<div class="uk-button-group" data-uk-switcher="{connect:'#my-id'}">
    <button class="uk-button" type="button">...</button>
</div>

<!-- This is the container of the content items -->
<ul id="my-id" class="uk-switcher uk-margin">...</ul>

Switcher with navs

To apply the switcher to the Nav component, add the data attribute to the nav <ul>. Use the Grid component to arrange nav and content in a grid layout.

Example

Markup

<div class="uk-grid">
    <div class="uk-width-medium-1-4">

        <!-- This is the nav containing the toggling elements -->
        <ul class="uk-nav uk-nav-side" data-uk-switcher="{connect:'#my-id'}">
            <li><a href="">...</a></li>
        </ul>
    </div>
    <div class="uk-width-medium-3-4">

        <!-- This is the container of the content items -->
        <ul id="my-id" class="uk-switcher">
            <li>...</li>
        </ul>
    </div>
</div>

JavaScript options

This is an example of how to set options via attribute:

data-uk-switcher="{active:1}"
Option Possible value Default Description
connect CSS selector false Related items container
toggle CSS selector '> *' Toggle css selector, triggering content switching on click
active integer 0 Active index on init
animation mixed false Predefined animation name or any uk-animation class name.

Events

You can bind callbacks to following events for custom functionality:

Name Parameter Description
show.uk.switcher event, active item On switcher item show/change

Example

$('[data-uk-switcher]').on('show.uk.switcher', function(event, area){
    console.log("Switcher switched to ", area);
});

Scrollspy

Trigger events and animations while scrolling your page.

Usage

The scrollspy component listens to page scrolling and triggers events based on the scroll position. For example, if you scroll down a page and an element appears the first time in the viewport you can trigger a smooth animation to fade in the element.

Data attribute Description
data-uk-scrollspy="{cls:'MY-CLASS'}" Applies the class only the first time the element appears in the viewport.
data-uk-scrollspy="{cls:'MY-CLASS', repeat: true}" Applies the class everytime the element appears in the viewport.
data-uk-scrollspy="{cls:'MY-CLASS', delay:600}" Adds a delay in milliseconds to the animation.

Typically, classes from the Animation component are used together with the scrollspy.

Examples

This example uses the repeat: true option. Scroll up and down to see the triggered animations.

Fade

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Scale up

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Scale down

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Slide top

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Slide bottom

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Slide right

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Slide left

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Delay

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Delay

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Delay

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Delay

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Markup

<div data-uk-scrollspy="{cls:'uk-animation-fade'}">...</div>

<div data-uk-scrollspy="{cls:'uk-animation-fade', repeat: true}">...</div>

<div data-uk-scrollspy="{cls:'uk-animation-fade', delay:900}">...</div>

JavaScript options

This is an example of how to set options via attribute:

data-uk-scrollspy="{cls:'uk-animation-fade'}"
Option Possible value Default Description
cls string 'uk-scrollspy-inview' Class to add when element is in view
initcls string 'uk-scrollspy-init-inview' Class to add when element is in view for first time
topoffset integer 0 Top offset before triggering in view
leftoffset integer 0 Left osset before triggering in view
repeat boolean false Applies the in view class everytime the element appears in the viewport.
delay integer 0 Delay time in ms

Events

You can bind callbacks to following events for custom functionality:

Name Description
uk.scrollspy.init Triggered when the element is initially in the viewport
uk.scrollspy.inview Triggered when the element is in the viewport
uk.scrollspy.outview Triggered when the element leaves the viewport

Example

$('[data-uk-scrollspy]').on('uk.scrollspy.inview', function(){
    // custom code...
});

Scrollspy Nav

To automatically update the active menu item in a menu depending on the scroll position of your site, just add the data attribute data-uk-scrollspy-nav to any navigation. Each menu item must link to the ID of its corresponding part of the site.

Data attribute Description
data-uk-scrollspy-nav Triggers the JavaScript necessary for the functionality of the scrollspy nav.
data-uk-scrollspy-nav="{closest:'MY-SELECTOR'}" Looks for the closest element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
data-uk-scrollspy-nav="{smoothscroll:true}" Applies the Smooth scroll component when skipping between different sections of the site.
data-uk-scrollspy-nav="{cls:'MY-CLASS'}" By default ScrollspyNav toggles the uk-active class. Use the cls option to use your own class name.

Markup

<ul class="uk-nav uk-nav-side" data-uk-scrollspy-nav="{closest:'li', smoothscroll:true}">
    <li><a href="#MY-ID">...</a></li>
    <li><a href="#MY-ID2">...</a></li>
</ul>

<div id="MY-ID">...</div>
<div id="MY-ID2">...</div>

JavaScript options

This is an example of how to set options via attribute:

data-uk-scrollspy-nav="{smoothscroll:true}"
Option Possible value Default Description
cls string 'uk-active' Class to add to active element
closest CSS selector false Element selector to aply the active class to
topoffset integer 0 Sroll top-offsset
leftoffset integer 0 Sroll left-offsset
smoothscroll boolean false Scroll animation

Events

Name Parameter Description
init.uk.scrollspy event On scrollspy first init
inview.uk.scrollspy event Element entered view-port
outview.uk.scrollspy event Element left view-port

Modal

Create modal dialogs with different styles and transitions.

Usage

The modal component consists of an overlay, a dialog and a close button.

Class Description
.uk-modal Add this class to a <div> element to create the dialog container and an overlay that blanks out the page. It is important to add an id to indicate the element for toggling.
.uk-modal-dialog Add this class to a child <div> element to create the dialog box.
.uk-modal-close Add this class to an <a> or <button> element to create a close button within the dialog box. We recommend adding the .uk-close class from the Close component to give the button a proper styling, though you can also use text or an image.

You can use any element to toggle a modal dialog. An <a> element needs to be linked to the modal's id. To enable the necessary JavaScript, add the data-uk-modal attribute. If you are using another element, like a button, just add the data-uk-modal="{target:'#ID'}" attribute to target the modal's id.

Example

Open

Markup

<!-- This is an anchor toggling the modal -->
<a href="#my-id" data-uk-modal>...</a>

<!-- This is a button toggling the modal -->
<button class="uk-button" data-uk-modal="{target:'#my-id'}">...</button>

<!-- This is the modal -->
<div id="my-id" class="uk-modal">
    <div class="uk-modal-dialog">
        <a class="uk-modal-close uk-close"></a>
        ...
    </div>
</div>

JavaScript options

By default, the modal closes automatically when clicking on the modal overlay. To prevent this from happening, just add the data-uk-modal="{target:'#ID',bgclose:false}" attribute.


You can create a header and footer for your modal, which are seperated from the content. Just add the .uk-modal-header or the .uk-modal-footer class to a <div> element inside the modal dialog.

Example

Headline

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Markup

<div class="uk-modal">
    <div class="uk-modal-dialog">
        <div class="uk-modal-header">...</div>
        ...
        <div class="uk-modal-footer">...</div>
    </div>
</div>

You can also create a caption that will be placed outside the modal. Just add the .uk-modal-caption class to a <div> element inside the modal dialog.

Example

Headline

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Caption

Markup

<div class="uk-modal">
    <div class="uk-modal-dialog">
        <div class="uk-modal-caption">...</div>
    </div>
</div>

To place a spinning icon inside your modal, add the .uk-modal-spinner class to a <div> element inside the modal dialog.

Example

Open

Markup

<div class="uk-modal">
    <div class="uk-modal-dialog">
        <div class="uk-modal-spinner">...</div>
    </div>
</div>

To create a lightbox-like modal dialog, just add the .uk-modal-dialog-lightbox class. This can be useful, if you want to use the modal as a lightbox for your images. The close button will adjust its position automatically to the dialog.

Example

Markup

<!-- This is the anchor toggling the modal -->
<a href="#my-id" data-uk-modal>...</a>

<!-- This is the modal -->
<div id="my-id" class="uk-modal">
    <div class="uk-modal-dialog uk-modal-dialog-lightbox">
        <a href="" class="uk-modal-close uk-close uk-close-alt"></a>
        <img src="" alt="">
    </div>
</div>

NOTE When creating a close button within the lightbox modifier, we also recommend adding the .uk-close-alt class from the Close component to the close button to give your button a styling that fits the lightbox modal.


Center Modal

To vertically center the modal, add the {center:true} option to the data-attribute.

Example

Open

Markup

<a href="#my-id" data-uk-modal="{center:true}"></a>

Large dialog modifier

To apply the site's container width to the modal dialog, just add the .uk-modal-dialog-large class.

Example

Open

Markup

<div class="uk-modal-dialog uk-modal-dialog-large">...</div>

Overflow container in modal

You can also display the modal's content in a scrollable container. Just add the .uk-overflow-container class to a <div> element inside the modal dialog. The modal will automatically expand and fill the site's height.

Example

Open

Markup

<div class="uk-modal-dialog">
    <p>...</p>
    <div class="uk-overflow-container">...</div>
    <p>...</p>
</div>

JavaScript

You can handle modal dialogs via raw javascript.

Example

var modal = UIkit.modal(".modalSelector");

if ( modal.isActive() ) {
    modal.hide();
} else {
    modal.show();
}

Events

The modal component triggers an show.uk.modal event every time a modal is opened and hide.uk.modal when a modal is closed.

Example

$('.modalSelector').on({

    'show.uk.modal': function(){
        console.log("Modal is visible.");
    },

    'hide.uk.modal': function(){
        console.log("Element is not visible.");
    }
});

Events

Name Parameter Description
show.uk.modal event On modal show
hide.uk.modal event On modal hide

Dropdown

Defines different styles for a toggleable dropdown.

Usage

Any content, like a button, can toggle a dropdown. Just wrap the toggle with a <div> element and add the data-uk-dropdown attribute. Add the .uk-dropdown class to a child <div> element to create the dropdown itself. A dropdown can be enabled by either hovering or clicking the the toggle.

Data attribute Description
data-uk-dropdown Opens the dropdown on hover and adds a little delay, so the dropdown won't disappear immediately, once you stop hovering the toggle.
data-uk-dropdown="{mode:'click'}" Opens the dropdown by clicking the toggle. The dropdown closes again on the next click.

IMPORTANT To apply a dropdown, it is important that a parent element has a relative position to align the dropdown properly. Many components create the position context by default, like the Button, Navbar, Subnav and the Tab component.

Example

NOTE In this example we are using a button from the Button component as a toggle.

Markup

<!-- This is the container enabling the JavaScript -->
<div data-uk-dropdown>

    <!-- This is the element toggling the dropdown -->
    <div>...</div>

    <!-- This is the dropdown -->
    <div class="uk-dropdown">...</div>

</div>

<!-- This is the container enabling the JavaScript in click mode -->
<div data-uk-dropdown="{mode:'click'}">

    <!-- This is the element toggling the dropdown -->
    <div>...</div>

    <!-- This is the dropdown -->
    <div class="uk-dropdown">...</div>

</div>

Delayed dropdowns in hover mode

You can set a delay parameter in milliseconds to prevent the immediate appearance of the dropdown.

Markup

<div class="uk-dropdown" data-uk-dropdown="{delay: 1000}">
    ...
</div>

Dropdown with navs

A dropdown can contain a nav from the Nav component. Just add the .uk-nav class and the .uk-nav-dropdown modifier to a <ul> element.

Markup

<div class="uk-dropdown">
    <ul class="uk-nav uk-nav-dropdown">...</ul>
</div>

Alignment modifiers

Add one of the following classes to align the dropdown menu.

Class Description
.uk-dropdown-flip Aligns the dropdown menu to the right.
.uk-dropdown-up Aligns the dropdown menu above the toggle.
.uk-dropdown-center Centers the dropdown menu.

Example

Markup

<div class="uk-dropdown uk-dropdown-flip">
    ...
</div>

<div class="uk-dropdown uk-dropdown-up">
    ...
</div>

<div class="uk-dropdown uk-dropdown-center">
    ...
</div>

Justify dropdown

To justify a dropdown, just add the data-uk-dropdown="{justify:'#ID'}" attribute. The parent element, to which the dropdown should be justified, needs to have the target id, so the dropdown will expand to the full width of the targeted element.

Example

Markup

<!-- This is the parent element to which the dropdown is being justified -->
<div id="my-id">

    <!-- This is the container enabling the JavaScript -->
    <div class="uk-button-dropdown" data-uk-dropdown="{justify:'#my-id'}">

        <!-- This is the element toggling the dropdown -->
        <button class="uk-button">...</button>

        <!-- This is the dropdown -->
        <div class="uk-dropdown">...</div>
    </div>
</div>

Automatic dropdown flip

By default, the dropdown flips automatically when it exceeds the viewport's edge. If you want to flip it according to a container's boundary, just add the data-uk-dropdown="{boundary:'#ID'}" attribute, using a selector for the container.

Example

Markup

<div id="my-id">
    <div class="uk-button-dropdown" data-uk-dropdown="{boundary:'#my-id'}">...</div>
</div>

Grid

You can even place a grid from the Grid component inside a dropdown, which can hold a navigation or any other content. Just wrap the content with a <div> and add the .uk-grid class. To optimize the grid for use inside the dropdown, add the .uk-dropdown-grid class. Add one of the .uk-dropdown-width-* classes to the grid's child elements to multiply the dropdown's width by up to 5.

Example

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.

Markup

<div class="uk-dropdown uk-dropdown-width-2">

    <div class="uk-grid uk-dropdown-grid">
        <div class="uk-width-1-2">
            <ul class="uk-nav uk-nav-dropdown uk-panel">...</ul>
            <div class="uk-panel">...</div>
        </div>

        <div class="uk-width-1-2">
            <div class="uk-panel">...</div>
        </div>
    </div>

</div>

Responsive behavior

In narrower viewports, like phones, there might not be enough space for the dropdown to expand. In that case the dropdown flips its alignment. Should there still not be enough space, the grid columns take up full width and stack vertically inside the dropdown.


Small modifier

By default, the dropdown has a fixed width and the text is wrapping into the next line. If you want your dropdown to be smaller, so that it extends to the width of its content without the text wrapping, add the .uk-dropdown-small class. This is useful for button dropdowns.

Example

Markup

<div class="uk-dropdown uk-dropdown-small">...</div>

Scrollable modifier

To give the dropdown a fixed height and enable its content to scroll, just add the .uk-dropdown-scrollable class.

Example

Markup

<div class="uk-dropdown uk-dropdown-scrollable">...</div>

Dropdowns are an essential part of a navbar from the Navbar component. Just add the .uk-dropdown-navbar class to the dropdown, so the dropdown fits perfectly into the navbar.

Example

Markup

<nav class="uk-navbar">
    <ul class="uk-navbar-nav">

        <!-- This is the container enabling the JavaScript -->
        <li class="uk-parent" data-uk-dropdown>

            <!-- This is the menu item toggling the dropdown -->
            <a href="">...</a>

            <!-- This is the dropdown -->
            <div class="uk-dropdown uk-dropdown-navbar">
                <ul class="uk-nav uk-nav-navbar">
                    <li><a href="">...</a></li>
                </ul>
            </div>

        </li>
    </ul>
</nav>

A button from the Button component can be used to trigger a dropdown menu.

Example

Markup

<!-- This is the container enabling the JavaScript -->
<div class="uk-button-dropdown" data-uk-dropdown>

    <!-- This is the button toggling the dropdown -->
    <button class="uk-button">...</button>

    <!-- This is the dropdown -->
    <div class="uk-dropdown uk-dropdown-small">
        <ul class="uk-nav uk-nav-dropdown">
            <li><a href="">...</a></li>
            <li><a href="">...</a></li>
        </ul>
    </div>

</div>

Dropdown in button groups

Use button groups from the Button component to split buttons into a standard action and a dropdown toggle.

Example

Markup

<div class="uk-button-group">

    <!-- This is a button -->
    <button class="uk-button">...</button>

    <!-- This is the container enabling the JavaScript -->
    <div data-uk-dropdown="{mode:'click'}">

        <!-- This is the button toggling the dropdown -->
        <a href="" class="uk-button">...</a>

        <!-- This is the dropdown -->
        <div class="uk-dropdown uk-dropdown-small">
            <ul class="uk-nav uk-nav-dropdown">
                <li><a href="">...</a></li>
                <li><a href="">...</a></li>
            </ul>
        </div>

    </div>
</div>

Dropdowns can also be applied to a subnav from the Subnav component.

Example

Markup

<ul class="uk-subnav uk-subnav-pill">
    <li><a href="">...</a></li>

    <!-- This is the container enabling the JavaScript -->
    <li data-uk-dropdown="{mode:'click'}">

        <!-- This is the nav item toggling the dropdown -->
        <a href="">...</a>

        <!-- This is the dropdown -->
        <div class="uk-dropdown uk-dropdown-small">
            <ul class="uk-nav uk-nav-dropdown">
                <li><a href="">...</a></li>
            </ul>
        </div>

    </li>
</ul>

Dropdowns can be used on a tab from the Tab component.

Example

Markup

<ul class="uk-tab" data-uk-tab>
    <li><a href="">...</a></li>

    <!-- This is the container enabling the JavaScript -->
    <li data-uk-dropdown="{mode:'click'}">

        <!-- This is the menu item toggling the dropdown -->
        <a href="">...</a>

        <!-- This is the dropdown -->
        <div class="uk-dropdown uk-dropdown-small">
            <ul class="uk-nav uk-nav-dropdown">
                <li><a href="">...</a></li>
            </ul>
        </div>
    </li>
</ul>

JavaScript options

This is an example of how to set options via attribute:

data-uk-dropdown="{mode:'hover'}"
Option Possible value Default Description
mode hover, click hover Dropdown trigger behaviour
remaintime integer 800 Remain time before auto closing dropdown in hover mode
justify CSS selector false Stretch dropdown width to a specified element
boundary window CSS selector Referenced element to keep dropdowns visibilty
delay integer 0 Delay time in hover mode before a dropdown is shown in ms

Events

You can bind callbacks to following events for custom functionality:

Name Description
show.uk.dropdown Triggered on dropdown show
stack.uk.dropdown Triggered when a dropdown stacks to fit into screen

Example

$('[data-uk-dropdown]').on('show.uk.dropdown', function(){
    // custom code...
});

Text

A collection of useful text utility classes to style your content.

Text styles

UIkit offers various text utlities to style your text.

Class Description
.uk-text-small Add this class to decrease the font size.
.uk-text-large Add this class to increase the font size.
.uk-text-bold Add this class to create bold text.
.uk-text-muted Add this class to mute your text.
.uk-text-primary Add this class for additional text information.
.uk-text-success Add this class to indicate success.
.uk-text-warning Add this class to indicate a warning.
.uk-text-danger Add this class to indicate danger.
.uk-text-contrast Add this class to make the text color readable on flat color areas or pictures. It's often white.

Text alignment

Add one of these useful classes to align your text.

Class Description
.uk-text-left Aligns text to the left.
.uk-text-right Aligns text to the right.
.uk-text-center Centers text horizontally.
.uk-text-center-small Centers text horizontally only on small devices.
.uk-text-center-medium Centers text horizontally on medium and small devices.
.uk-text-justify Justifies text.

Example

Lorem ipsum dolor sit amet, consetetur sadipscing elitr. .uk-text-left
Lorem ipsum dolor sit amet, consetetur sadipscing elitr. .uk-text-right
Lorem ipsum dolor sit amet, consetetur sadipscing elitr. .uk-text-center
Lorem ipsum dolor sit amet, consetetur sadipscing elitr. .uk-text-center-small
Lorem ipsum dolor sit amet, consetetur sadipscing elitr. .uk-text-center-medium
Lorem ipsum dolor sit amet, consetetur sadipscing elitr. .uk-text-justify

Vertical alignment

Add one of these classes to vertically align text to an object.

Class Description
.uk-text-top Aligns text to the top.
.uk-text-middle Centers text vertically.
.uk-text-bottom Aligns text to the bottom.

Example

Lorem ipsum.
Lorem ipsum.
Lorem ipsum.

Text wrapping

Add one of these useful classes to wrap your text.

Class Description
.uk-text-truncate Prevents text from wrapping into multiple lines, truncating it instead.
.uk-text-break Breaks strings if their length exceeds the width of their container.
.uk-text-nowrap Prevents text from wrapping into multiple lines.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt. Lorem ipsum dolor sit amet, consetetur sadipscing elit .uk-text-truncate
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt. Lorem ipsum dolor sit amet, consetetur sadipscing elit .uk-text-break

Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac.

.uk-text-nowrap

More Articles ...

Chameleon I.T are a client focused consultancy seeking to deliver IT efficiency gains through software and consulting solutions.

These solutions seek to take existing systems and optimise them in conjunction with adding cutting edge technologies to complement.

 

Map

Contact us

Phone:
01727 831 383
Email:
info@chameleonit.co.uk
Mon-Fri:
9am to 5pm

Search