Grid

The responsive layout grid adapts to screen size and orientation, ensuring consistency across layouts.

The grid creates visual consistency between layouts while allowing flexibility across a wide variety of designs. Unifi’s responsive UI is based on a 12-column grid layout.

How it works

The grid system is implemented with the Grid component:

  • It uses CSS’s Flexible Box module for high flexibility.
  • There are two types of layout: containers and items.
  • Item widths are set in percentages, so they’re always fluid and sized relative to their parent element.
  • Items have padding to create the spacing between individual items.
  • There are five grid breakpoints: xs, sm, md, lg, and xl.

Spacing

The responsive grid focuses on consistent spacing widths, rather than column width. Unifi design margins and columns follow an 8dp square baseline grid. Spacing is defined as multiples of 8, with available values of 0 - 10.

Constrained Grid

For a layout that would benefit from a max width to prevent extending to screen edges on large displays to cap line length and content width, use the constrained prop on a <Grid container>

The default is 1200px and a string can be passed to set a custom value.

Note: Does not affect alignment. If you wish to achieve a common, centered layout, also add margin={{ x: 'auto'}} as a prop.

Fluid Grids

Fluid grids use columns that scale and resize content. A fluid grid’s layout can use breakpoints to determine if the layout needs to change dynamically.

Basic Grid

The column widths apply at all breakpoints (i.e. xs and up).

Grid with Breakpoints

Some columns have multiple widths defined, causing the layout to change at the defined breakpoint.

Interactive Grid Demo

Below is an interactive demo that lets you explore the visual results of the different settings:

Auto-Layout

The Auto-layout makes the items equitably share the available space. That also means you can set the width of one item and the others will automatically resize around it.

Nested Grid

The container and item properties are two independent booleans. They can be combined.

A flex container is the box generated by an element with a computed display of flex or inline-flex. In-flow children of a flex container are called flex items and are laid out using the flex layout model.

Properties