Flex

Arrange elements with direction, alignment, spacing, and wrapping.

Live preview
Interact with the component to see results here.
View code
HTML
<sy-flex
  direction="horizontal"
  justify="start"
  align="center"
  wrap="wrap"
  row-gap="small"
  column-gap="small"
  padding="small"
  height="180px"
>
  <sy-button variant="primary">Save</sy-button>
  <sy-button>Preview</sy-button>
  <sy-button>Cancel</sy-button>
</sy-flex>

Usage guide

#

Use to align items along one axis, such as button groups or toolbars. Use Layout for the overall page structure.

Main-axis alignment

justify positions items along the axis specified by direction.

Cross-axis alignment

align aligns items on the perpendicular axis. Changing direction changes both axes.

Examples

#

Action button row

Keep consistent spacing and wrap items onto the next line as the width narrows.

View code
HTML
<sy-flex
  wrap="wrap"
  padding="none"
  column-gap="small"
>
  <sy-button variant="primary">Save</sy-button>
  <sy-button>Preview</sy-button>
  <sy-button>Cancel</sy-button>
</sy-flex>

Vertical layout

Stack items vertically and stretch them along the cross axis.

View code
HTML
<sy-flex
  direction="vertical"
  align="stretch"
  padding="none"
  row-gap="small"
>
  <sy-button variant="primary">Save</sy-button>
  <sy-button>Preview</sy-button>
  <sy-button>Cancel</sy-button>
</sy-flex>

Space between

Place primary and secondary actions at opposite ends.

View code
HTML
<sy-flex
  justify="space-between"
  align="center"
  padding="none"
  wrap="wrap"
>
  <sy-button>Back</sy-button>
  <sy-button variant="primary">Continue</sy-button>
</sy-flex>

Spacing across multiple rows

Set row and column gaps separately.

View code
HTML
<sy-flex
  wrap="wrap"
  row-gap="medium"
  column-gap="small"
  padding="none"
>
  <sy-button>Item 1</sy-button>
  <sy-button>Item 2</sy-button>
  <sy-button>Item 3</sy-button>
  <sy-button>Item 4</sy-button>
  <sy-button>Item 5</sy-button>
  <sy-button>Item 6</sy-button>
  <sy-button>Item 7</sy-button>
  <sy-button>Item 8</sy-button>
</sy-flex>

API reference

#

Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.

<sy-flex>

Properties

Attribute / PropertyTypeDefaultDescription
FlexAlign'start'Alignment perpendicular to the main axis.
FlexGap'medium'Spacing token between rows.
FlexGap'medium'Spacing token between columns.
FlexJustify'start'Alignment along the main axis.
FlexDirection'horizontal'Horizontal, vertical, or reverse layout direction.
FlexWrap'nowrap'How items wrap when width or height is insufficient.
FlexGap'medium'Spacing token used for padding.
string''Width as a CSS length or a numeric string interpreted as pixels.
string''Height as a CSS length or a numeric string interpreted as pixels.

Slots

SlotDescription
Component body or child items.