Form

Easily create nicely looking forms with different styles and layouts.

Usage

To apply this component, add the .uk-form class to a form element. All form control elements are placed side by side within the next row.

Example

Form

NOTE In this example we used a button from the Button component. To add a top margin to form elements, when they stack on smaller viewports, just add the data-uk-margin attribute from the Utility component to the parent element.

Markup

<form class="uk-form">

    <fieldset data-uk-margin>
        <legend>...</legend>
        <input type="text" placeholder="">
        <input type="password" placeholder="">
        <select>
            <option>...</option>
            <option>...</option>
        </select>
        <button class="uk-button">...</button>
        <label><input type="checkbox"> ...</label>
    </fieldset>

</form>

Rows

Add the .uk-form-row class to a <div> element to stack form controls.

Example

Legend

Markup

<form class="uk-form">
    <fieldset>
        <legend>...</legend>
        <div class="uk-form-row">...</div>
        <div class="uk-form-row">...</div>
    </fieldset>
</form>

Control states

Provide the user with basic information through feedback states on form controls.

Disabled

Add the disabled attribute to a form control and it will be appear muted.

Example

Markup

<input type="text" placeholder="" disabled>

Validation states

Add the .uk-form-danger or .uk-form-success class to a form control to notify the user, whether or not the value is validated.

Example

Markup

<input type="text" placeholder="" class="uk-form-danger">
<input type="text" placeholder="" class="uk-form-success">

Control modifiers

Size modifiers

Add the .uk-form-large or .uk-form-small class to an <input>, <select> or <textarea> element to make it smaller or larger.

Example

Markup

<input type="text" placeholder="" class="uk-form-large">
<input type="text" placeholder="" class="uk-form-small">

Width modifiers

Add the .uk-form-width-large, .uk-form-width-medium, .uk-form-width-small or .uk-form-width-mini class to an <input>, <select> or <textarea> element to adjust its width.

Example

Markup

<input type="text" placeholder="" class="uk-form-width-large">
<input type="text" placeholder="" class="uk-form-width-medium">
<input type="text" placeholder="" class="uk-form-width-small">
<input type="text" placeholder="" class="uk-form-width-mini">

You can also apply the .uk-width-* classes from the Grid component to form controls. This is especially useful, if you want form controls to extend to the full width of their parent container.

Example

Markup

<input type="text" placeholder="" class="uk-width-1-1">

Form blank

Add the .uk-form-blank class to minimize the styling of form controls.

Example

Markup

<input type="text" placeholder="" class="uk-form-blank">

Help text

Use the .uk-form-help-inline or .uk-form-help-block class to add inline and block level help text for the controls.

Example

The .uk-form-help-inline class creates spacing to the left.

The .uk-form-help-block class creates an associated paragraph.

Markup

<div class="uk-form-row">
    <input type="text" placeholder=""> <span class="uk-form-help-inline">...</span>
</div>

<div class="uk-form-row">
    <textarea cols="" rows="" placeholder="">...</textarea>
    <p class="uk-form-help-block">...</p>
</div>

Layout modifiers

There are two layout modifiers available: .uk-form-stacked and .uk-form-horizontal. Both require form controls to be wrapped with the .uk-form-row class in order to stack them. Labels need the .uk-form-label class and controls must be wrapped in the .uk-form-controls class.

Markup

<form class="uk-form uk-form-stacked">
    <div class="uk-form-row">
        <label class="uk-form-label" for="">...</label>
        <div class="uk-form-controls">...</div>
    </div>
</form>

NOTE Layout modifiers can also be added to a <fieldset> element. This means, if you use fieldsets, you can have different form layouts for each fieldset.


Form stacked

Add the .uk-form-stacked class to display labels on top of controls.

Example

Radio input

Checkbox input

Mixed controls

Form horizontal

Add the .uk-form-horizontal class to display labels and controls side by side.

Example

Radio input

Checkbox input

Mixed controls

Text in form controls

If you use text and checkboxes or radio buttons in form controls, just add the .uk-form-controls-text class to align the text properly.

Markup

<div class="uk-form-controls uk-form-controls-text">...</div>

Vertical spacing in form controls

If you create paragraphs in form controls, add the .uk-form-controls-condensed class to reduce spacing.

Example

Mixed controls

Markup

<div class="uk-form-controls uk-form-controls-text">
    <p class="uk-form-controls-condensed">...</p>
    <p class="uk-form-controls-condensed">...</p>
</div>

Form and grid

This is an example of how to use forms with the Grid component.

Example

Markup

<form class="uk-form">

    <div class="uk-grid">
        <div class="uk-width-1-2"><input type="text" placeholder="" class="uk-width-1-1"></div>
        <div class="uk-width-1-4"><input type="text" placeholder="" class="uk-width-1-1"></div>
        <div class="uk-width-1-4"><input type="text" placeholder="" class="uk-width-1-1"></div>
    </div>

</form>

Form and icons

This is an example of how to add an icon from the Icon component to a form.

Example

Markup

<div class="uk-form-icon">
    <i class="uk-icon-calendar"></i>
    <input type="text">
</div>

Form advanced

Table

Easily create nicely looking tables, which come in different styles.

Usage

To apply this component, add the .uk-table class to a table. The table rows will be separated by lines.

Example

Table caption
Table Heading Table Heading Table Heading
Table Footer Table Footer Table Footer
Table Data Table Data Table Data
Table Data Table Data Table Data
Table Data Table Data Table Data

Markup

<table class="uk-table">
    <caption>...</caption>
    <thead>
        <tr>
            <th>...</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <td>...</td>
        </tr>
    </tfoot>
    <tbody>
        <tr>
            <td>...</td>
        </tr>
    </tbody>
</table>

Columns

To modify the column width or content, you can use other components. Here are some useful examples:

Style Description
Column width Add one of the .uk-width-* classes from the Grid component.
Text alignment Add the .uk-text-left, .uk-text-right or .uk-text-center class from the Text component.
Text style Take a look at the Text component. For example add the .uk-text-bold class.

Markup

<td class="uk-width-1-10 uk-text-right">...</td>
<td class="uk-width-9-10 uk-text-bold">...</td>

Vertical modifier

To vertically center table content, just add the .uk-table-middle class to the <tr> or <td> elements.


Modifiers

To display the table in a different style, just add a modifier to the the .uk-table class.

Table hover

Add the .uk-table-hover class to display a hover state on table rows.

Example

Table Heading Table Heading Table Heading
Table Data Table Data Table Data
Table Data Table Data Table Data
Table Data Table Data Table Data

Markup

<table class="uk-table uk-table-hover">...</table>

Table striped

Add zebra-striping to a table by adding the .uk-table-striped class.

Example

Table Heading Table Heading Table Heading
Table Data Table Data Table Data
Table Data Table Data Table Data
Table Data Table Data Table Data

Markup

<table class="uk-table uk-table-striped">...</table>

Table condensed

Add the .uk-table-condensed class to make table cells more compact.

Example

Table Heading Table Heading Table Heading
Table Data Table Data Table Data
Table Data Table Data Table Data
Table Data Table Data Table Data

Markup

<table class="uk-table uk-table-condensed">...</table>

Combine modifiers

The modifiers of the Table component are combinable with each other.

Example

Table Heading Table Heading Table Heading
Table Data Table Data Table Data
Table Data Table Data Table Data
Table Data Table Data Table Data

Markup

<table class="uk-table uk-table-hover uk-table-striped uk-table-condensed">...</table>

Responsive Table

If your table happens to be wider that its container element or would eventually get too big on a specific viewport width, just wrap it inside a <div> element and add the .uk-overflow-container class. This creates a container that provides a horizontal scrollbar whenever the elements inside it are wider than the container itself.

Example

Table Heading Table Heading Table Heading Table Heading Table Heading Table Heading Table Heading Table Heading
Table Footer Table Footer Table Footer Table Footer Table Footer Table Footer Table Footer Table Footer
Table Data Table Data Table Data Table Data Table Data Table Data Table Data Table Data
Table Data Table Data Table Data Table Data Table Data Table Data Table Data Table Data
Table Data Table Data Table Data Table Data Table Data Table Data Table Data Table Data

Markup

<div class="uk-overflow-container">
    <table>...</table>
</div>

Tab

Create a tabbed navigation with different styles.

Usage

The Tab component consists of clickable tabs, that are aligned side by side.

Class Description
.uk-tab Add this class to a <ul> element to define the Tab component. Use <a> elements as tab items within the list.
.uk-active Add this class to a list item to apply an active state.
.uk-disabled Add this class to a list item to apply a disabled state.

The data-uk-tab attribute is required for two purposes. Firstly, it enables the responsive behaviour. If the parent container is too small to accomodate all tabs, they will be combined into a dropdown, toggled by a single tab, which represents the active tab item. This also requires the Dropdown component in order to work.

And secondly, its functionality is coupled to the Switcher component, which is necessary to dynamically transition through different contents using tabbed navigation.

Example

Markup

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

Horizontal modifiers

Add one of the following classes to alter your tabs' styling. These modifiers can also be combined.

Align tabs

Class Description
.uk-tab-flip Add this class to align tabs right and in reversed order.
.uk-tab-bottom Add this class to the <ul> to place tabs at the bottom. This can also be combined with the other modifiers.

Example

Markup

<ul class="uk-tab uk-tab-flip" data-uk-tab>...</ul>
<ul class="uk-tab uk-tab-bottom" data-uk-tab>...</ul>

Justify tabs

Add the .uk-tab-grid class and one of the .uk-width-* classes from the Grid component to the list items to arrange tabs in a grid that takes up full width of its parent element.

Example

Markup

<ul class="uk-tab uk-tab-grid uk-tab-bottom" data-uk-tab>
    <li class="uk-width-1-3"><a href="">...</a></li>
</ul>

Center tabs

Add the .uk-tab-center class to a <div> element around the tabbed navigation to center tabs.

Example

Markup

<div class="uk-tab-center">
    <ul class="uk-tab" data-uk-tab>...</ul>
</div>

Vertical modifiers

Add the .uk-tab-left or .uk-tab-right class to align tabs vertically to the left or right side.

Example

Markup

<ul class="uk-tab uk-tab-left uk-width-medium-1-2">
    <li>...</li>
</ul>
<ul class="uk-tab uk-tab-right uk-width-medium-1-2">
    <li>...</li>
</ul>

Responsive behavior

In narrower viewports, like phones, vertical tabs align themselves horizontally. Adding the data-uk-tab attribute will apply the same responsive behavior as horizontal tabs.


Tabs with dropdowns

This is an example of how to use tabs with the Dropdown component.

Example

Markup

<ul class="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>

Utility

A collection of useful utility classes to style your content.

Container

Add the .uk-container class to a block element to give it a max-width and wrap the main content of your website. For large screens it applies a different max-width.


Centering

To center the container, use the .uk-container-center class. For any other block element, you additionally need to apply a width.

Example

Centered block element

Markup

<div class="uk-width-medium-1-2 uk-container-center">...</div>

Clearing and floating

Floating is fundamental for creating all kinds of layouts. But floats need to be cleared or in the worst case, you might end up with a scrambled site. The following classes will help you to setup basic layouts.

Class Description
.uk-float-left Float the element to the left.
.uk-float-right Float the element to the right.
.uk-clearfix Add this class to a parent container to clear floats.

Markup

<div class="uk-clearfix">
    <div class="uk-float-right">...</div>
    <div class="uk-float-left">...</div>
</div>

New block formatting context

Instead of using the .uk-clearfix class, you can create a new block formatting context to clear floats. Depending on your setup, you can evaluate which method is more suited.

Class Description
.uk-nbfc Sets overflow to hidden to create a new block formatting context.
.uk-nbfc-alt Sets display to table-cell to create a new block formatting context.

Alignment of images and objects

Align images or other elements with spacing between the text and the element.

Class Description
.uk-align-left Floats the element to the left and creates right and bottom margin.
.uk-align-right Floats the element to the right and creates left and bottom margin.
.uk-align-medium-left Only affects device widths of 768px and higher.
.uk-align-medium-right Only affects device widths of 768px and higher.
.uk-align-center Centers the element and creates bottom margin.

Example

Image aligned to the rightLorem 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

<p class="uk-clearfix">
    <img class="uk-align-medium-right" src="" alt="">
    ...
</p>

Vertical alignment

To align objects vertically, you need to create a parent container to which the object itself will be aligned.

Class Description
.uk-vertical-align Add this class to the parent container. This container needs a specific height.
.uk-vertical-align-middle Add this class to the child element to center your content.
.uk-vertical-align-bottom Add this class to the child element to align your content to the bottom.
.uk-height-1-1 This helper class applies a height of 100%.

Example

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Markup

<div class="uk-vertical-align">
    <div class="uk-vertical-align-middle">
    ...
    </div>
</div>
<div class="uk-vertical-align">
    <div class="uk-vertical-align-bottom">
    ...
    </div>
</div>

NOTE The object you align needs to have a width or max-width that is smaller than its parent container.

Center the entire page

The .uk-height-1-1 class comes in handy, if you want to extend the <html> and <body> elements to the full height of the page. This can be very useful when creating error pages.

Markup

<html class="uk-height-1-1">
    ...
    <body class="uk-height-1-1">
        <div class="uk-vertical-align">
            <div class="uk-vertical-align-middle">...</div>
        </div>
    </body>
</html>

Center horizontally

To center your content horizontally as well, add the .uk-text-center class to the parent and the .uk-container-center class to the child element. This is necessary because of the responsive behavior.


Viewport height

To create a container that fills the height of the entire viewport, for example for fullscreen image or video teasers, just add the .uk-height-viewport class.


Position elements

UIkit provides a number of classes to position your content without having to add your own CSS.

Class Description
.uk-position-top Positions an element absolute at the top.
.uk-position-bottom Positions an element absolute at the bottom.
.uk-position-cover Adds absolute positioning to an element and stretches it to cover the entire parent.
.uk-position-relative Adds relative positioning to an element.

Responsive objects

Images in UIkit adapt to the width of their parent container by default. If you want to apply the responsive behavior to media elements, like a video object, just add one of the following classes.

Class Description
.uk-responsive-width Adjusts the object's width according to its parent's width, keeping the original aspect ratio.
.uk-responsive-height Adjusts the object's height according to its parent's height, keeping the original aspect ratio.

NOTE The .uk-responsive-width class can also be applied to an Iframe, provided its width and height attributes are set.

Example width

Example height

Markup

<video controls class="uk-responsive-width"></video>

<img class="uk-responsive-height" src="" alt="">

Margin

Add one of the following classes to add spacing to block elements.

Class Description
.uk-margin Adds the same top and bottom margins as a paragraph usually has.
.uk-margin-top Adds top margin.
.uk-margin-bottom Adds bottom margin.
.uk-margin-left Adds left margin.
.uk-margin-right Adds right margin.

Larger margin

Add one of the following classes to add larger spacing to block elements.

Class Description
.uk-margin-large Adds large top and bottom margin.
.uk-margin-large-top Adds large top margin.
.uk-margin-large-bottom Adds large bottom margin.
.uk-margin-large-left Adds large left margin.
.uk-margin-large-right Adds large right margin.

Smaller margin

Add one of the following classes to add smaller spacing to block elements.

Class Description
.uk-margin-small Adds small top and bottom margin.
.uk-margin-small-top Adds small top margin.
.uk-margin-small-bottom Adds small bottom margin.
.uk-margin-small-left Adds small left margin.
.uk-margin-small-right Adds small right margin.

Remove margin

Add one of the following classes to remove spacing from block elements.

Class Description
.uk-margin-remove Removes all margins.
.uk-margin-top-remove Removes top margin.
.uk-margin-bottom-remove Removes bottom margin.

Auto margin

To add spacing to stacking elements, for example inline elements that wrap on smaller vieports, just add the data-uk-margin attribute to their parent container. It will automatically add the .uk-margin-small-top to the lower element.

Example

Markup

<p data-uk-margin>
    <button class="uk-button">...</button>
    <button class="uk-button">...</button>
</p>

NOTE By default, the data attribute adds the .uk-margin-small-top class to stacking elements. To apply a bigger margin, just add the {cls:'.uk-margin-top'} option.


Border radius

To add rounded corners to an element, like an image, just add the .uk-border-rounded. To a apply a circled shape, add the .uk-border-circle class.

Example

Border rounded Border circle

<img class="uk-border-rounded" src="" alt="">
<img class="uk-border-circle" src="" alt="">

Heading large

To increase the font size of your headings on tablets and desktops, just add the .uk-heading-large class.

Example

Heading

Markup

<h1 class="uk-heading-large">...<h1>

If a link should not have the default link color, just add the .uk-link-muted class to the anchor element or the parent element.

Example

Markup

<a class="uk-link-muted">...<a>

<h1 class="uk-link-muted"><a>...<a><h1>

<ul class="uk-link-muted">
    <li><a>...<a></li>
    <li><a>...<a></li>
    <li><a>...<a></li>
</ul>

Scrollable preformatted text

Add the .uk-scrollable-text class to set a max-height and provide a vertical scrollbar. This is very useful for preformatted text, if you don't want your code blocks to take too much space.

Example

<!-- This is sample code to demonstrate preformatted text with a scrollbar. -->

<div class="uk-grid">
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-left">...</div>
    </div>
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-right">...</div>
    </div>
</div>
<div class="uk-grid">
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-center">...</div>
    </div>
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-justify">...</div>
    </div>
</div>

<div class="uk-grid">
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box uk-text-break">...</div>
    </div>
    <div class="uk-width-medium-1-2">
        <div class="uk-panel uk-panel-box"><p class="uk-margin-remove uk-text-truncate">...</p></div>
    </div>
</div>

Scrollable box

Add the .uk-scrollable-box class to create a panel-like box which has a max-height and provides a vertical scrollbar. It can contain any kind of content.

Example

Markup

<div class="uk-scrollable-box">
    <ul class="uk-list">
        <li><label><input type="checkbox">...</label></li>
        <li><label><input type="checkbox">...</label></li>
    </ul>
</div>

Overflow container

To create a container that provides a horizontal scrollbar whenever the elements inside it are wider than the container itself, just add the .uk-overflow-container class to a <div> element. This comes in useful when having to handle tables on a responsive website, which at some point would just get too big.

Example

Table Heading Table Heading Table Heading Table Heading Table Heading Table Heading Table Heading Table Heading
Table Footer Table Footer Table Footer Table Footer Table Footer Table Footer Table Footer Table Footer
Table Data Table Data Table Data Table Data Table Data Table Data Table Data Table Data
Table Data Table Data Table Data Table Data Table Data Table Data Table Data Table Data
Table Data Table Data Table Data Table Data Table Data Table Data Table Data Table Data

Markup

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

Display utilities

Add one of these classes to change the display properties of an element.

Class Description
.uk-display-block Forces the element to behave like a block element.
.uk-display-inline Forces the element to behave like an inline element.
.uk-display-inline-block Forces the element to behave like an inline-block element.

Visibility utilities

Class Description
.uk-hidden Hides the element on any device.
.uk-hidden-touch Hides the element on touch devices.
.uk-hidden-notouch Hides the element on non-touch devices.
.uk-invisible Hides the element without removing it from the flow.
.uk-visible-hover Displays hidden content on hover using display: block. Add this class to the parent element.
.uk-visible-hover-inline Displays hidden content on hover using display: inline-block. Add this class to the parent element.

Example

Hover me...
Bazinga!

Markup

<div class="uk-visible-hover">
    <div class="uk-hidden">...</div>
</div>

Responsive visibility

You can show or hide content on specific viewport widths. Breakpoints are set through variables and can easily be modified. Since the line between different device sizes keeps blurring, class names are kept general and do not refer to particular devices.

Class Small
(Phones)
up to 767
Medium
(Tablets)
768 to 959
Large
(Desktops)
960 and larger
.uk-visible-small Visible Hidden Hidden
.uk-visible-medium Hidden Visible Hidden
.uk-visible-large Hidden Hidden Visible
.uk-hidden-small Hidden Visible Visible
.uk-hidden-medium Visible Hidden Visible
.uk-hidden-large Visible Visible Hidden

Grid

Create a fully responsive, fluid and nestable grid layout.

The grid system of UIkit follows the mobile-first approach and accomodates up to 10 grid columns. It uses units with predefined classes inside each grid, which define the column width. It is also possible to combine the grid with classes from the Flex component, although it works only in modern browsers.


Usage

To create the grid container, add the .uk-grid class to a parent element. Add one of the .uk-width-* classes to child elements to determine, how the units shall be sized. The grid supports 1, 2, 3, 4, 5, 6 and 10 unit divisions. This table gives you an overview of the uk-width-* classes that can be applied to units.

Class Description
.uk-width-1-1 Fills 100% of the available width.
.uk-width-1-2 Divides the grid into halves.
.uk-width-1-3 to .uk-width-2-3 Divides the grid into thirds.
.uk-width-1-4 to .uk-width-3-4 Divides the grid into fourths.
.uk-width-1-5 to .uk-width-4-5 Divides the grid into fifths.
.uk-width-1-6 to .uk-width-5-6 Divides the grid into sixths.
.uk-width-1-10 to .uk-width-9-10 Divides the grid into tenths.

We built an intentional redundancy into each set of unit classes, so that for instance the .uk-width-5-10 class will work just as well as .uk-width-1-2.

Example

Take a closer look at the following grid example, which gives you a great overwiew of all basic .uk-width-* classes.

.uk-width-1-3
.uk-width-1-3
.uk-width-1-3
.uk-width-1-2
.uk-width-1-2
.uk-width-3-10
.uk-width-7-10

NOTE The grid has no style related CSS. In our example we used panels from the Panel component.

Markup

Here is a simple code example of how the default grid with 2 columns would look like:

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

Responsive width

UIkit provides a number of very useful responsive widths classes. Basicall they work just like the usual width classes, except they are prefixed, so that they only come to effect at certain breakpoints. These classes can be combined with the visibility classes from the Utility component. This is great to adjust your layout and content for different device sizes.

Class Description
.uk-width-* Affects all device widths, grid columns stay side by side.
.uk-width-small-* Affects device widths of 480px and higher. Grid columns will stack on smaller sizes.
.uk-width-medium-* Affects device widths of 768px and higher. Grid columns will stack on smaller sizes.
.uk-width-large-* Affects device widths of 960px and higher. Grid columns will stack on smaller sizes.

IMPORTANT To create a margin between stacking grid columns, just add the data-uk-grid-margin attribute.

Example

.uk-width-medium-1-2 .uk-width-large-1-3
.uk-hidden-medium .uk-width-large-1-3
.uk-width-medium-1-2 .uk-width-large-1-3
.uk-width-1-2 .uk-width-medium-1-3
.uk-hidden-small .uk-width-medium-1-3
.uk-width-1-2 .uk-width-medium-1-3
.uk-width-1-1 .uk-visible-small
.uk-width-medium-1-1 .uk-visible-medium
.uk-width-large-1-1 .uk-visible-large

Grid gutter

Grids automatically create a horizontal gutter between columns and a vertical one between two succeeding grids. By default, the grid gutter is wider on large screens. To avoid this behavior and preserve the originial spacing, just add the .uk-grid-preserve class.

Example

Lorem ipsum
Lorem ipsum
Lorem ipsum

Small gutter

To apply a smaller gutter between grid columns, just add the .uk-grid-small class.

Example

Lorem ipsum
Lorem ipsum
Lorem ipsum

Nested grid

You can easily extend your grid layout with nested grids.

Example

.uk-width-1-2
.uk-width-1-2
.uk-width-1-2

Markup

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

Center grid

Add the .uk-container-center class from the Utility component to center a grid column.

Example

.uk-container-center

Grid divider

Add the .uk-grid-divider class to separate grid columns with lines. To separate grids with a horizontal line, just add the class to a <hr> or <div> element.

Example

.uk-width-medium-1-3
.uk-width-medium-1-3
.uk-width-medium-1-3

.uk-width-medium-1-3
.uk-width-medium-1-3
.uk-width-medium-1-3

Markup

<div class="uk-grid uk-grid-divider">...</div>
<hr class="uk-grid-divider">
<div class="uk-grid uk-grid-divider">...</div>

NOTE The horizontal divider can not be applied to grids with any of the uk-push-* or uk-pull-* classes.


Source ordering

You can change the display order of the columns to keep a specific column order in the source code. Add one of the .uk-push-* classes to move the column to the right and add one of the .uk-pull-* classes to move a column to the left. This allows you for example to flip the columns' display order for wider viewports. The classes can also be used to offset columns, creating additional space between them.

Source ordering is useful for SEO and responsive design, because in narrow viewports the grid will be displayed according to the source order of the markup.

NOTE This feature only works in combination with one of the .uk-width-medium-* classes.

Example

.uk-width-medium-1-2 .uk-push-1-2
.uk-width-medium-1-2 .uk-pull-1-2
.uk-width-medium-2-5 .uk-push-3-5
.uk-width-medium-2-5 .uk-pull-2-5

Markup

<div class="uk-grid">
    <div class="uk-width-medium-1-2 uk-push-1-2">...</div>
    <div class="uk-width-medium-1-2 uk-pull-1-2">...</div>
</div>

Match column heights

The Grid component uses Flexbox, so the height of grid columns is matched automatically. To achieve the same effect in older browsers that don't support Flexbox, just add the data-uk-grid-match attribute to your grid. If your grid wraps into multiple rows, only grid columns within the same row are matched. To match grid columns accross all rows just use data-uk-grid-match="{row: false}".

Example

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

Markup

<div class="uk-grid" data-uk-grid-match>...</div>

NOTE If grid columns extend to a width of 100%, their heights will no longer be matched. This makes sense, for example, if they stack vertically in narrower viewports.


Match height of panels

If you want to match the heights of panels in a grid, just add the .uk-grid-match class. When using the data attribute, you need to add the {target:'.uk-panel'} selector.

Example

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

Markup

<div class="uk-grid uk-grid-match" data-uk-grid-match="{target:'.uk-panel'}">
    <div class="uk-width-medium-1-3">
        <div class="uk-panel">...</div>
    </div>
</div>

Wrap multiple rows

You can also create a grid with as many columns as you want, which automatically break into the next line. Just add the data-uk-grid-margin attribute to create a margin between the grid rows. Typically this layout is built using a <ul> element.

Example

  • Box
  • Box
  • Box
  • Box
  • Box
  • Box

NOTE You can also apply a custom width to your grid columns. Just add the .uk-width class and use an inline style to define the width. This example uses fixed pixel values for the widths as you would do with images.

  • Box
  • Box
  • Box
  • Box
  • Box
  • Box
  • Box
  • Box

Markup

<ul class="uk-grid" data-uk-grid-margin>

    <!-- These elements have a width in percent -->
    <li class="uk-width-medium-1-5">...</li>
    <li class="uk-width-medium-3-10">...</li>

    <!-- These elements have a width in pixel -->
    <li class="uk-width" style="width: 100px;">...</li>
    <li class="uk-width" style="width: 150px;">...</li>

</ul>

Even grid columns

To create a grid whose child elements' widths are evenly split, you don't have to apply the same class to each list item within the grid. Just add one of the .uk-grid-width-* classes to the grid itself.

Class Description
.uk-grid-width-1-2 Divides the grid into halves.
.uk-grid-width-1-3 Divides the grid into thirds.
.uk-grid-width-1-4 Divides the grid into fourths.
.uk-grid-width-1-5 Divides the grid into fifths.
.uk-grid-width-1-6 Divides the grid into sixths.
.uk-grid-width-1-10 Divides the grid into tenths.

Example

  • Box
  • Box
  • Box
  • Box
  • Box

Markup

<ul class="uk-grid uk-grid-width-1-5">
    <li>...</li>
    <li>...</li>
</ul>

Responsive width

UIkit also provides responsive grid width classes. You can apply these to maintain evenly sized grid columns, regardless of the device width.

Class Description
.uk-grid-width-* Affects all device widths.
.uk-grid-width-small-* Affects device widths of 480px and higher.
.uk-grid-width-medium-* Affects device widths of 768px and higher.
.uk-grid-width-large-* Affects device widths of 960px and higher.
.uk-grid-width-xlarge-* Affects device widths of 1220px and higher.

Example

  • Box
  • Box
  • Box
  • Box
  • Box

Markup

<ul class="uk-grid uk-grid-width-1-2 uk-grid-width-medium-1-3 uk-grid-width-large-1-5">
    <li>...</li>
    <li>...</li>
</ul>

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