Section

Create horizontal layout sections with different background colors and styles.

Notice

This documentation is a work in progress.

Usage

Sections are used to separate the content of a page into differently styled blocks. To apply this component, just add the .uk-section class to a container element. You can place a container from the Container component to modify the width of the content inside sections and add horizontal padding. Note that the padding of a nested container will be reset.

<div class="uk-section">
  <div class="uk-container"></div>
</div>

By default, a section is blank. That is why it is important to add a modifier class for styling. In our example we are using the .uk-section-muted class. Normally, the section is the outermost element of a page, so this example doesn’t quite reflect the realistic usage of this component.

Copy to clipboard
  • Section

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

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

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

  • <div class="uk-section uk-section-muted">
      <div class="uk-container">
        <h3>Section</h3>
    
        <div class="uk-child-width-1-3@m uk-grid-match" uk-grid>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
        </div>
      </div>
    </div>

Style modifiers

To apply different background colors and paddings, add one of the following classes.

ClassDescription
.uk-section-defaultAdds the default background color of your site.
.uk-section-mutedAdds a muted background color.
.uk-section-primaryAdds a primary background color.
.uk-section-secondaryAdds a secondary background color.
<div class="uk-section uk-section-primary"></div>
Copy to clipboard
  • Section Default

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

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

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

    Section Muted

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

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

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

    Section Primary

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

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

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

    Section Secondary

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

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

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

    Section with Images

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

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

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

  • <div class="uk-section uk-section-default">
      <div class="uk-container">
        <h3>Section Default</h3>
    
        <div class="uk-child-width-1-3@m uk-grid-match" uk-grid>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
        </div>
      </div>
    </div>
    
    <div class="uk-section uk-section-muted">
      <div class="uk-container">
        <h3>Section Muted</h3>
    
        <div class="uk-child-width-1-3@m uk-grid-match" uk-grid>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
        </div>
      </div>
    </div>
    
    <div class="uk-section uk-section-primary">
      <div class="uk-container">
        <h3>Section Primary</h3>
    
        <div class="uk-child-width-1-3@m uk-grid-match" uk-grid>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
        </div>
      </div>
    </div>
    
    <div class="uk-section uk-section-secondary">
      <div class="uk-container">
        <h3>Section Secondary</h3>
    
        <div class="uk-child-width-1-3@m uk-grid-match" uk-grid>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
        </div>
      </div>
    </div>
    
    <div class="uk-section-default">
      <div
        class="uk-section uk-background-cover text-muted-foreground"
        style="background-image: url(/images/dark.jpg)"
      >
        <div class="uk-container">
          <h3>Section with Images</h3>
    
          <div class="uk-child-width-1-3@m uk-grid-match" uk-grid>
            <div>
              <p>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
                eiusmod tempor.
              </p>
            </div>
            <div>
              <p>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
                eiusmod tempor.
              </p>
            </div>
            <div>
              <p>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
                eiusmod tempor.
              </p>
            </div>
          </div>
        </div>
      </div>
    </div>

Preserve color

The .uk-section-primary and .uk-section-secondary classes are extending the inverse style from the Inverse component automatically. If you want to prevent this behavior, for example because you are using cards in these sections, add the .uk-preserve-color class.

<div class="uk-preserve-color uk-section uk-section-primary"></div>
Copy to clipboard
  • Section Primary with cards

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

    Lorem ipsum dolor sit amet, consectetur adipisicing elit.

  • <div class="uk-preserve-color uk-section uk-section-primary">
      <div class="uk-container">
        <div class="uk-margin-medium uk-panel">
          <h3>Section Primary with cards</h3>
        </div>
    
        <div class="uk-child-width-expand@m uk-grid-match" uk-grid>
          <div>
            <div class="uk-card uk-card-body uk-card-default">
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
            </div>
          </div>
          <div>
            <div class="uk-card uk-card-body uk-card-default">
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
            </div>
          </div>
        </div>
      </div>
    </div>

Size modifier

You can add different paddings to each section or remove it altogether.

ClassDescription
.uk-section-xsmallAdd this class to decrease a section’s padding to a minimum.
.uk-section-smallAdd this class to decrease a section’s padding.
.uk-section-largeAdd this class to increase a section’s padding.
.uk-section-xlargeAdd this class to further increase a section’s padding.
.uk-padding-remove-verticalAdd this class from the Padding component to remove a section’s padding.
Copy to clipboard
  • Section Large

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

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

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

  • <div class="uk-section uk-section-large uk-section-muted">
      <div class="uk-container">
        <h3>Section Large</h3>
    
        <div class="uk-child-width-1-3@m uk-grid-match" uk-grid>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
          <div>
            <p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor.
            </p>
          </div>
        </div>
      </div>
    </div>

Overlap modifier

Some UIkit themes use richer styles, including textured backgrounds and borders. In this case, you can add the .uk-section-overlap class, to apply a border image and a negative offset to the following section. Note that this only works in styles that implement the feature, if there are subsequent sections.

<div class="uk-section uk-section-overlap"></div>

Theme development

On your tailwind.config.js file, add the Section component within the ui() plugin.

import ui from "franken-ui";

ui({
    components: {
        section: {
            hooks: {},
            media: true
        }
    }
}),