Width

Define the width of elements for different viewport sizes.

Width

Define the width of elements for different viewport sizes.

UIkit’s Width component is often used in combination with grids to split content into responsive columns. You can apply fractions, automatic width or expand units to fill the remaining space and combine these modes.


Usage

Add one of the .uk-width-* classes to an element to determine its size. Typically, you would use a grid from the Grid component and its child elements to create the units.

ClassDescription
.uk-width-1-1Fills 100% of the available width.
.uk-width-1-2The element takes up halves of its parent container.
.uk-width-1-3, .uk-width-2-3The element takes up thirds of its parent container.
.uk-width-1-4, .uk-width-3-4The element takes up fourths of its parent container.
.uk-width-1-5, .uk-width-2-5,
.uk-width-3-5, .uk-width-4-5
The element takes up fifths of its parent container.
.uk-width-1-6, .uk-width-5-6The element takes up sixths of its parent container.

Note We remove redundancy into each set of unit classes, so that for instance instead of .uk-width-3-6 you should use .uk-width-1-2.

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

Auto & expand

The Width component provides additional modifiers to give you more flexibility in the distribution of items.

ClassDescription
.uk-width-autoThe item expands only to the width of its own content.
.uk-width-expandThe item expands to fill up the remaining space of the grid container.
<div uk-grid>
    <div class="uk-width-auto"></div>
    <div class="uk-width-expand"></div>
</div>

Equal child widths

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-child-width-* classes to the grid itself.

ClassDescription
.uk-child-width-1-2All elements take up half of their parent container.
.uk-child-width-1-3All elements take up a third of their parent container.
.uk-child-width-1-4All elements take up a fourth of their parent container.
.uk-child-width-1-5All elements take up a fifth of their parent container.
.uk-child-width-1-6All elements take up a sixth of their parent container.
.uk-child-width-autoDivides the grid into equal units depending on the content size.
.uk-child-width-expandDivides the grid into equal units depending on the available space.
<div class="uk-child-width-1-4" uk-grid>
    <div></div>
    <div></div></div>

Items that use width classes with fractions will break into a new row, if they no longer fit their container’s width. When using one of the expand classes, however, the space will be evenly distributed among items that always stay in the same row.

<div class="uk-child-width-expand" uk-grid>
    <div></div>
    <div></div></div>

Fixed width

In addition to the calculated width classes, you can also add one of the following classes, which apply fixed widths.

ClassDescription
.uk-width-smallApplies a fixed width of 150px.
.uk-width-mediumApplies a fixed width of 300px.
.uk-width-largeApplies a fixed width of 450px.
.uk-width-xlargeApplies a fixed width of 600px.
.uk-width-2xlargeApplies a fixed width of 750px.
<div class="uk-width-medium"></div>

Mixing widths

You can also combine .uk-child-width-* classes with .uk-width-* classes for individual items. That way it is possible, for example, to create a grid with one item that has a specific width and all other items expanding to fill the remaining space.

<div class="uk-child-width-expand" uk-grid>
    <div></div>
    <div class="uk-width-1-3"></div>
    <div></div></div>

Responsive width

UIkit provides a number of responsive widths classes. Basically they work just like the usual width classes, except that they have suffixes that represent the breakpoint from which they come to effect. These classes can be combined with the Visibility component. This is great to adjust your layout and content for different device sizes.

ClassDescription
.uk-width-*
.uk-child-width-*
Affects all device widths, grid columns stay side by side.
.uk-width-*@s
.uk-child-width-*@s
Affects device widths of 640px and larger. Grid columns will stack on smaller sizes.
.uk-width-*@m
.uk-child-width-*@m
Affects device widths of 960px and larger. Grid columns will stack on smaller sizes.
.uk-width-*@l
.uk-child-width-*@l
Affects device widths of 1200px and larger. Grid columns will stack on smaller sizes.
.uk-width-*@xl
.uk-child-width-*@xl
Affects device widths of 1600px and larger. Grid columns will stack on smaller sizes.