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

You can easily build custom pages with Flexbox layouts in UI Builder. Customizing the layout of your page lets you take full advantage of Flexbox so that you can achieve your overall page design. For more information, see Organize components in UI Builder pages.

Flexbox is a one-dimensional layout system in CSS. Flexbox is inherently flexible, which is useful for when you don’t know the size of your content. If you plan to build complex pages, you can customize the layout of your page in the configuration panel styles tab or with CSS. Visit Mozilla to learn more about Flexbox.

You can change the direction of your content in the layout in the following ways:
  • Row: Rows are organized left-to-right or right-to-left, depending on the direction of your browser's default language. Left/right is the case for an English browser.
  • Row-reverse: Rows are organized in the reverse direction of your browser's default language, such as right-to-left or left-to-right.
  • Column: Up/down or down/up
  • Column-reverse: Down/up
    Figure 1. Flexbox row and column directions
    Diagram showing Flexbox row and column directions.
  • Justify content: Defines the alignment along the main axis. Choices are as follows:
    • Flex-start: Items are at the start of the flex direction, similar to left-justified content. This is the default setting.
    • Flex-end: Items are at the end of the flex direction, similar to right-justified content.
    • Space-between: Items are distributed evenly.
    • Space-around: Items are distributed evenly with equal space around them.
    • Space-evenly: The spacing between items is equal.
  • Align items: Defines how you want your flex content displayed along the cross axis. Choices are as follows:
    • Stretch: Stretch your content to fill the container. This is the default setting
    • Flex-start: Place your content at the start of the cross axis.
    • Flex-end: Place your content at the end of the cross axis.
    • Center: Center your content in the cross axis.
    • Base system: Align your content the same as your baseline alignment.
  • Height: Set the height automatically or manually.
  • Width: Set the height of your flexbox items automatically or manually.
  • Margin: Set your minimal distance between flexbox items.
  • Padding: Set the padding for each side of your flexbox items.

Create a Flexbox layout with the new layout system

Create a Flexbox 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 Flexbox in the layouts tab.
    Arrow pointing to the Flexbox option on the layouts tab of the toolbox.
  6. Select Add.
  7. Select the Styles tab in the configuration panel.
  8. In the Layout section, you should see Flexbox highlighted.
    Arrow pointing to the Flexbox option on the configuration panel styles tab.
  9. In the Layout section of the styles tab, you can change the following:
    Direction
    Define how you want components to stack, horizontally or vertically.
    Align Items
    Define how components within containers align as a group.
    Justify content
    Define how to pack or space apart the components within the container.
    Note: Select Show advanced layout options to see the next two options.
    Gap
    Set the size of the gap between rows and columns.
    Wrap child elements to multiple lines
    Set whether components are forced onto one line or overflow onto multiple lines.

    Visit Mozilla to learn more about Flexbox layout configurations.

  10. (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.
  11. Select Save.
    Your page refreshes and displays the changes made to the layout.
  12. Add components to your page.
    See Add and configure components for more information.
  13. View and test your page by selecting Preview button that opens the page variant..

Create a Flexbox layout with the old layout system

Create a Flexbox 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 Flexbox to change the CSS code 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-column layout.
    Figure 2. Standard two-column-layout
    Standard two-column-layout.
  5. Click Edit layout code.
    Figure 3. Edit the layout code
    Edit the layout code.
  6. Expand the code editor so that you can easily view the CSS code.
    Figure 4. Expand the code editor
    Arrow pointing to expand the code editor button.
  7. Add another slot to the layout by copying the CSS code for an existing slot.

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

    Figure 5. Copy the CSS code for a slot
    Arrow pointing to copy the CSS code for a slot.
  8. Below the code that you copied, place a comma and then paste the following CSS code:
    1. Change the "slotName" property to "Column 3",.
    2. Change the "flex" property to "2".
    3. Add "margin-left": "1rem".
    Figure 6. Paste the CSS code
    Pasting the CSS code.

    Changing the "flex" property increases the size of the column. By using "margin-left", you add space between the previous columns.

  9. Collapse the expanded view, and then click Apply.
    Figure 7. Apply a layout change
    Applying a layout change.

Result

The new Flexbox layout that you created shows the new slot that you added to the original two-column layout.
Figure 8. New custom layout
New, finished custom layout.
Click Reset to original to reset layout changes back to the original.
Figure 9. Reset a layout
Arrow pointing to reset to original option.