Flex
A flexbox container component with convenient props for direction, alignment, justification, wrapping, and gap. Simplifies common flexbox patterns.
Anatomy
<script>
import { Flex } from "@saas-ui/svelte/layout/flex";
</script>
<Flex direction="row" align="center" justify="between" gap={4}>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</Flex>Examples
Basic Accessibility
gap.
<Flex>
<DecorativeBox class="h-10 flex-1" />
<DecorativeBox class="h-10 flex-1" />
<DecorativeBox class="h-10 flex-1" />
</Flex> Direction Accessibility
direction prop to change flex direction: row, column, row-reverse, or column-reverse.
<Flex gap={4} direction="column">
<DecorativeBox class="h-10" />
<DecorativeBox class="h-10" />
<DecorativeBox class="h-10" />
</Flex> Justify Accessibility
justify prop to control content distribution: start, center, end, between, around, or evenly.
<Flex direction="column" gap={4}>
<Flex justify="start">
<DecorativeBox class="h-10 w-32" />
<DecorativeBox class="h-10 w-32">flex-start</DecorativeBox>
<DecorativeBox class="h-10 w-32" />
</Flex>
<Flex justify="center">
<DecorativeBox class="h-10 w-32" />
<DecorativeBox class="h-10 w-32">center</DecorativeBox>
<DecorativeBox class="h-10 w-32" />
</Flex>
<Flex justify="end">
<DecorativeBox class="h-10 w-32" />
<DecorativeBox class="h-10 w-32">flex-end</DecorativeBox>
<DecorativeBox class="h-10 w-32" />
</Flex>
<Flex justify="between">
<DecorativeBox class="h-10 w-32" />
<DecorativeBox class="h-10 w-32">space-between</DecorativeBox>
<DecorativeBox class="h-10 w-32" />
</Flex>
</Flex>Props
| Prop | Type | Default | Description |
|---|---|---|---|
direction | row | column | row-reverse | column-reverse | row | The flex direction. |
align | start | center | end | stretch | baseline | - | Shorthand for alignItems. |
justify | start | center | end | between | around | evenly | - | Shorthand for justifyContent. |
wrap | wrap | nowrap | wrap-reverse | - | Shorthand for flexWrap. |
gap | number | - | The gap between children. |
children | any | - | The content to be rendered inside the component. |
class | text | - | Additional CSS classes to apply. |