Create a CSS Grid layout in UI Builder to build powerful pages so that you can customize with cascading style sheets (CSS) and can improve your performance.

CSS Grid is the most powerful layout system in CSS. CSS Grid is built on top of a two-dimensional grid. CSS Grid gives you control over how you create your pages. Use UI Builder to implement a CSS Grid layout using low-code layout configuration properties. For advanced layouts, you can view and edit CSS code to customize your layouts. Visit Mozilla to learn more about CSS Grid.

For example, you can have a grid with three columns and three rows to make a grid nine cells. You can place components inside these cells or make the component span multiple cells.

Figure 1. CSS Grid layout
CSS Grid layout

Customizing the layout of your page lets you take full advantage of CSS Grid so that you can achieve your overall page design. For more information, see Organize components in UI Builder pages.

To find out more about CSS layouts within your UI Builder instance, you can find them in the [sys_uib_template] table.

Create a CSS Grid layout with the new layout system

Create a CSS Grid layout in UI Builder to build powerful pages in a low-code environment.

Before you begin

Role required: admin

Procedure

  1. Navigate to All > Now Experience Framework > UI Builder.
  2. Open an experience to work in or create an experience by selecting Create > Experience.
    See Configure how users interact with your applications in UI Builder for more information on creating experiences.
  3. Create a page in UI Builder.
  4. Select the + Add content button in the UI Builder stage.
  5. Select Grid in the layouts tab.
    Arrow pointing to the Grid option in the layouts tab of the toolbox.
  6. Select the Styles tab in the configuration panel.
  7. In the Layout section, you should see Grid highlighted.
    Arrow pointing to the Grid option in the configuration panel styles tab.
  8. In the Layout section of the styles tab, you can change the following:
    Columns
    Defines the number, order, and width of grid columns.
    Rows
    Defines the number, order, and width of grid rows.
    Direction
    Sets whether newly added components are stacked horizontally or vertically.
    Gap
    Sets the size of the gap between rows and columns.
    Note: Select Show advanced layout options to see the next four options.
    Align items
    Defines how components within the container align as a group.
    Justify items
    Defines how the browser distributes space between and around content items along the inline axis of a grid container.
    Align content
    Sets the distribution of space between and around content items along a grid's block axis.
    Justify content
    Defines how to pack or space apart the components within the container.

    Visit Mozilla to learn more about CSS Grid layout configurations.

  9. (Optional) You can edit the CSS code by selecting Show advanced configuration options at the bottom of the Styles tab, and then selecting the View and edit CSS option.
  10. Select Save.
    Your page refreshes and displays the changes made to the layout.
  11. Add components to your page.
    See Add and configure components for more information.
  12. View and test your page by selecting Preview button that opens the page variant..

Create a CSS Grid layout with the old layout system

Create a CSS Grid layout in UI Builder to build powerful pages so that you can customize with cascading style sheets (CSS) and can improve your performance.

Before you begin

Role required: admin

About this task

In the following procedure, you learn how to use CSS Grid to modify your CSS to customize the layout of your page.

Procedure

  1. Navigate to All > Now Experience Framework > UI Builder.
  2. Open an experience to work in or create an experience by selecting Create > Experience.
    See Configure how users interact with your applications in UI Builder for more information on creating experiences.
  3. Create a page in UI Builder or open a page.
  4. Click the Layout tab and choose the two-row by two-column layout.
    Figure 2. Standard two-row, two-column layout
    Standard two row, two-column layout.
  5. Click Edit layout code.
    Figure 3. Edit the layout code
    Edit layout code option.
  6. Expand the code editor so that you can easily view the CSS code.
    Figure 4. Expand the code editor
    Arrow pointing to the expand the code editor button.
  7. Add another slot to the layout by copying the CSS code for an existing slot.

    Copying the CSS code is easier than typing it into the layout.

    Figure 5. Copy the CSS code for a slot
    Arrow pointing to copying the CSS code for a slot.
  8. Paste the CSS code below the code that you copied and change the slotName and grid-area to a unique value.
    Figure 6. Paste the CSS code
    Pasting the CSS code.
  9. Modify the layout rules to include the new column and template area, as follows:
    1. Delete the "Grid-template-columns": "1fr 1fr", line.
    2. Add a second cell1 after cell1, and then add cell5 after cell4.
    Figure 7. Modify the layout rules
    Modifying the layout rules.

    You can set many different configurations. In this example, there are the two resulting grids from two different grid template areas. The "grid-template-areas" property being modified is setting the CSS property of the same name. For more information, see MDN grid-templates-areas.

    Figure 8. Grid template areas
    Grid template areas.
  10. Collapse the expanded view, and then click Apply.
    Figure 9. Apply a layout change
    Applying a layout change.

Result

The new CSS Grid layout shows that the new slot was added to the original two-row, two-column layout.
Figure 10. New custom layout
New custom layout.
Click Reset to original to reset the layout changes back to the original at any time.
Figure 11. Reset a layout
Arrow pointing to reset to original option.