Back to Onyx

Section

web/lib/opal/src/layouts/general/README.md

4.0.0-cloud.22.4 KB
Original Source

Section

Import: import { Section } from "@opal/layouts";

A flexbox container primitive for grouping related content. Configurable direction, alignment, spacing, and dimensions. Defaults to a full-width / full-height column with centered children and a 1rem gap.

Props

PropTypeDefaultDescription
flexDirection"row" | "column""column"Flex direction
justifyContent"start" | "center" | "end" | "between""center"Main-axis justification
alignItems"start" | "center" | "end" | "stretch""center"Cross-axis alignment
width"auto" | "fit" | "full" | number"full"Width. number = rem.
height"auto" | "fit" | "full" | number"full"Height. number = rem.
gapnumber1Gap between children, in rem
paddingnumber0Padding, in rem
wrapbooleanfalseEnables flex-wrap
dbgbooleanfalseAdds a red debug border
classNamestringAdditional classes
refRef<HTMLDivElement>Forwarded ref

Usage

tsx
import { Section } from "@opal/layouts";

// Column with default gap
<Section>
  <Card>First</Card>
  <Card>Second</Card>
</Section>

// Row, items aligned to start
<Section flexDirection="row" justifyContent="start" alignItems="center">
  <Button>Cancel</Button>
  <Button>Save</Button>
</Section>

// Tighter gap, custom width
<Section gap={0.5} width="fit">
  <Tag>One</Tag>
  <Tag>Two</Tag>
</Section>

Notes

  • <Disabled> from @opal/core uses display: contents and can wrap a Section without affecting layout.
  • Children stretch by default (alignItems="center" on the cross axis but width="full" on the wrapper). Override with alignItems="stretch" for typical form layouts.