Layout
import * as Layout from '@dxos/react-ui/Layout';Layout arranges children without hand-written flex or grid classes. Layout explains
how the primitives fit with Panel and ScrollArea. Every primitive takes classNames. Layout.Flex,
Layout.Grid and Layout.Container also take asChild.
Layout.Flex
Section titled “Layout.Flex”Layout.Flex lays children out on one axis.
| Prop | Type | Effect |
|---|---|---|
column |
boolean |
Stacks children on the block axis instead of the inline axis |
gap |
Gap |
Sets the space between children, as a step of the spacing ramp |
align |
'start' | 'center' | 'end' | 'baseline' | 'stretch' |
Aligns children on the cross axis. Children stretch by default |
justify |
'start' | 'center' | 'end' | 'between' | 'around' | 'evenly' |
Aligns children on the main axis, as CSS justify-content |
wrap |
boolean |
Wraps children onto more lines |
grow |
boolean |
Takes the parent’s slack and clips what overflows |
center |
boolean |
Centers children on both axes |
Layout.Grid
Section titled “Layout.Grid”Layout.Grid lays children out on two axes.
| Prop | Type | Effect |
|---|---|---|
cols |
number | 'subgrid' | GridTrack[] |
Sets the columns. 3 gives three equal columns, a list gives anything else, and 'subgrid' shares the parent’s |
rows |
number | 'subgrid' | GridTrack[] |
Sets the rows, the same way |
gap |
Gap |
Sets the space between cells |
align |
'start' | 'center' | 'end' | 'baseline' | 'stretch' |
Aligns children within each cell |
center |
boolean |
Centers children on both axes |
grow |
boolean |
Fills and clips the parent |
contents |
boolean |
Renders as display: contents, so children join the parent grid |
A GridTrack in the list is one of these:
'fill'takes the rest of the space, and can shrink.- A number takes a share of the rest, so
[2, 1]is two thirds and one third. 'min','max'and'auto'size the track to the content.- A length, such as
'12rem', gives the track that size.
A Gap is 'none', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', 'form' or 'form-section'. Use 'form' for the
spacing between fields, and 'form-section' for the spacing between groups of fields.
Layout.Container
Section titled “Layout.Container”Layout.Container puts content between two gutters, so rows line up with the panel’s edges.
| Prop | Type | Effect |
|---|---|---|
gutter |
'rail' | 'inset' | 'sm' | 'md' | 'lg' | 'none' | 'inherit' |
Sets the gutter width. rail leaves room for an icon column |
layout |
'stack' | 'row' |
Sets how children flow. row lays a child’s parts across the container’s tracks |
size |
Size |
Sets the size for everything inside. See Density and sizes |
Layout.Block
Section titled “Layout.Block”Layout.Block is one slot in a container’s rail, sized so a passive icon and an icon button line up. It takes
rail='start' or rail='end'.
Layout.Columns
Section titled “Layout.Columns”Layout.Columns is a horizontal run of as many columns as fit, each an equal share of the width. When there are more,
it scrolls a column at a time.
| Prop | Type | Effect |
|---|---|---|
minColumnWidth |
number |
Sets the narrowest a column may be, in rem. 24 by default |
maxColumns |
number |
Sets the most columns shown at once |
gap |
number |
Sets the space between columns, in rem. 0 by default |
follow |
boolean |
Scrolls to a newly added column. true by default |
Layout.Separator
Section titled “Layout.Separator”Layout.Separator is a rule between groups of content.