# Layout > Layout components that arrange a Widget's content: Card, Basic, Box, Col, Row, Form, Grid, Spacer, Divider, ListView, ListViewItem, CardCarousel and Stack Layout components hold and arrange everything else in a Widget. A Widget's outermost element must be one of `Card`, `Basic`, `CardCarousel`, `ListView`, `Box`, `Col` or `Row`; most Widgets start with a `Card`. > [!NOTE] > > Spacing values written as numbers use a 4-pixel scale: `gap={3}` is 12 px and `padding={4}` is 16 px. Write a string, such as `"12px"` or `"100%"`, to use an exact CSS length instead. `width`, `height` and the other size props take numbers as plain pixels. ## Common Layout Props `Box`, `Col`, `Row`, `Basic`, `Form` and `ListViewItem` share these props. | Prop | Type | Description | | - | - | - | | `padding` | number \| string \| `{top, right, bottom, left, x, y}` | Inner spacing. An object sets sides separately; `x` and `y` set both sides of an axis. | | `margin` | number \| string \| `{top, right, bottom, left, x, y}` | Outer spacing, in the same format as `padding`. | | `border` | number \| `{size, color?, style?}` | Border. A number is its width in pixels. An object can also set one side with `top`, `right`, `bottom`, `left`, `x` or `y`. | | `radius` | `none` \| `2xs` \| `xs` \| `sm` \| `md` \| `lg` \| `xl` \| `2xl` \| `3xl` \| `4xl` \| `full` \| number | Corner rounding, from 2 px (`2xs`) to 24 px (`4xl`). | | `background` | color | Background color. | | `width` | number \| string | Width. | | `height` | number \| string | Height. | | `size` | number \| string | Sets `width` and `height` together. | | `minWidth` | number \| string | Minimum width. | | `maxWidth` | number \| string | Maximum width. | | `minHeight` | number \| string | Minimum height. | | `maxHeight` | number \| string | Maximum height. | | `minSize` | number \| string | Sets `minWidth` and `minHeight` together. | | `maxSize` | number \| string | Sets `maxWidth` and `maxHeight` together. | | `aspectRatio` | number \| string | Fixed aspect ratio, such as `16/9`. | | `gap` | number \| string | Space between children. | | `align` | `start` \| `center` \| `end` \| `baseline` \| `stretch` | Cross-axis alignment. | | `justify` | `start` \| `center` \| `end` \| `between` \| `around` \| `evenly` \| `stretch` | Main-axis distribution. | | `flex` | number \| string | Flex grow and shrink. | | `wrap` | `nowrap` \| `wrap` \| `wrap-reverse` | Whether children wrap onto new lines. | Colors accept a theme token (`primary`, `secondary`, `tertiary`, `success`, `caution`, `warning`, `danger`, `info`, `discovery`, `surface`, `surface-secondary`, `surface-tertiary`, `surface-elevated`, `subtle`, `white`, `black`), a palette shade such as `blue-500` or `gray-100`, `alpha-40` for a see-through version of the current text color, any CSS color, or `{ light, dark }` for a different color in each theme. > [!TIP] > > Leave `gap` out and QwryAI spaces children with its own defaults, which suit most Widgets. Set it when you want exact spacing. ## Card The usual root container. A Card draws a bordered, rounded panel and can add confirm and cancel buttons under it. ```jsx <Text value={description} color="secondary" /> </Card> ``` ### Props | Prop | Type | Default | Description | | - | - | - | - | | `size` | `sm` \| `md` \| `lg` \| `full` | `sm` | Card width: 360 px, 440 px, 560 px or the full width of the chat. | | `padding` | number \| string \| object | `4` | Inner spacing. | | `background` | color | card color | Background color. | | `border` | number \| object | 1 px border | Border, as in the common props. | | `status` | `{text, icon?}` or `{text, favicon?, frame?}` | — | A small header line above the card, with an icon or a site icon. | | `confirm` | `{label, action}` | — | Adds a primary button under the card. `label` defaults to `Confirm`. | | `cancel` | `{label, action}` | — | Adds an outline button under the card. `label` defaults to `Cancel`. | | `asForm` | boolean | `false` | Makes the card a form: the confirm button submits every field inside it. | | `collapsed` | boolean | `false` | On the outermost card, starts with the body hidden behind the `status` line and a **Show details** control. | | `theme` | `light` \| `dark` | the chat's theme | Forces a color theme for the card and everything in it. | > [!NOTE] > > `confirm` and `cancel` take an action in the same shape as `onClickAction`, such as `{ functionName: "placeOrder" }`. With `asForm`, the confirm button submits the form and its function receives every field value. ## Basic A plain container with no card styling. Use it as a root when you want the Widget to sit directly in the chat, or to force a theme on part of a Widget. ```jsx <Basic gap={2} theme="dark" padding={4} background="gray-900" radius="xl"> <Text value="Members get free returns" /> </Basic> ``` ### Props `Basic` accepts all [common layout props](#common-layout-props) plus: | Prop | Type | Default | Description | | - | - | - | - | | `direction` | `row` \| `col` | `col` | Direction of its children. | | `theme` | `light` \| `dark` | the chat's theme | Forces a color theme inside the container. | ## Box A flex container for arranging children in either direction. ```jsx <Box direction="row" align="center" gap={3} padding={4}> <Icon name="star" /> <Text value="Featured" /> </Box> ``` ### Props `Box` accepts all [common layout props](#common-layout-props) plus: | Prop | Type | Default | Description | | - | - | - | - | | `direction` | `row` \| `col` | `col` | Flex direction. | | `flush` | boolean | `false` | Stretches to the edges of the parent, ignoring its padding. | | `scrollable` | boolean | `false` | Scrolls when the content overflows. | ## Col A vertical container: a `Box` that always stacks its children top to bottom. ```jsx <Col gap={2}> <Title value={title} size="sm" /> <Text value={subtitle} color="secondary" /> </Col> ``` ### Props `Col` accepts all [common layout props](#common-layout-props). ## Row A horizontal container: a `Box` that always places its children side by side. Children are centered vertically unless you set `align`. ```jsx <Row gap={3}> <Image src={avatar} size={40} radius="full" /> <Text value={name} weight="semibold" /> <Spacer /> <Button label="View" variant="outline" /> </Row> ``` ### Props `Row` accepts all [common layout props](#common-layout-props). > [!TIP] > > Put a `Spacer` between children of a `Row` to push them to opposite ends, a common pattern for headers and list rows. ## Form A container that collects the fields inside it and runs one function on submit. See [Form Inputs](/docs/developer-guides/widgets/components/form-inputs#form). `Form` accepts all [common layout props](#common-layout-props) plus `direction` and `onSubmitAction`. ## Grid A grid with a set number of columns. Each child is a `Grid.Item`. ```jsx <Grid columns={2} gap={2}> <Grid.Item> <Text value="Subtotal" /> </Grid.Item> <Grid.Item> <Text value={subtotal} textAlign="end" /> </Grid.Item> </Grid> ``` ### Grid Props | Prop | Type | Default | Description | | - | - | - | - | | `columns` | number \| string | equal columns that fit | A number of equal columns, or a CSS `grid-template-columns` value. | | `gap` | number \| string | `2` | Space between cells. | ### Grid.Item Props | Prop | Type | Default | Description | | - | - | - | - | | `span` | number | `1` | How many columns the item covers. | ## Spacer Flexible empty space that grows to fill the room along the parent's main axis. ```jsx <Row> <Text value="Left" /> <Spacer /> <Text value="Right" /> </Row> ``` ### Props | Prop | Type | Default | Description | | - | - | - | - | | `minSize` | number \| string | — | The smallest the spacer can shrink to. | ## Divider A horizontal line between sections. ```jsx <Col> <Text value="Items" /> <Divider flush /> <Text value="Total" /> </Col> ``` ### Props | Prop | Type | Default | Description | | - | - | - | - | | `spacing` | number \| string | automatic | Space above and below the line. | | `color` | color | border color | Line color. | | `size` | number \| string | `1` | Line thickness. | | `flush` | boolean | `false` | Stretches the line to the edges of the parent, ignoring its padding. | ## ListView A list of items, each a `ListViewItem`. When there are more items than `limit`, the list adds a **Show N more** button that expands it, and **Show less** to collapse it again. ```jsx <ListView limit={3} status={{ text: "Recent orders", icon: "shopping-bag" }}> {orders.map((order) => ( <ListViewItem key={order.number} gap={3}> <Text value={order.number} weight="medium" /> <Spacer /> <Badge label={order.status} color="info" /> </ListViewItem> ))} </ListView> ``` ### Props | Prop | Type | Default | Description | | - | - | - | - | | `limit` | number \| `"auto"` | `4` | How many items show before **Show N more**. `"auto"` shows them all. | | `orientation` | `horizontal` \| `vertical` | `vertical` | Lay the items out in a column or a scrolling row. | | `gap` | number \| string | automatic | Space between items. | | `status` | `{text, icon?}` or `{text, favicon?, frame?}` | — | A header line above the list. | | `theme` | `light` \| `dark` | the chat's theme | Forces a color theme for the list. | A `ListView` can contain `ListViewItem` elements, and [state](/docs/developer-guides/widgets/states) blocks around them. ## ListViewItem One row of a `ListView`. It lays its children out in a row, centered vertically, with a padding of `2.5` (10 px). Give it an `onClickAction` to make the whole row clickable. ```jsx <ListViewItem onClickAction={{ functionName: "openOrder", additionalInputs: { number: order.number } }} gap={3}> <Image src={order.thumbnail} size={40} /> <Text value={order.number} /> </ListViewItem> ``` ### Props `ListViewItem` accepts all [common layout props](#common-layout-props) plus: | Prop | Type | Default | Description | | - | - | - | - | | `onClickAction` | action | — | Function to run when the row is clicked. Makes the row a button with hover and keyboard focus. | ## CardCarousel A horizontally scrolling row of link cards, each a `CardLinkItem`. Use it for articles, products or locations a visitor can open. ```jsx <CardCarousel status={{ text: "Help articles", icon: "book-open" }}> {articles.map((article) => ( <CardLinkItem key={article.url} href={article.url} hrefLabel={article.title}> <Title value={article.title} size="sm" /> <Caption value={article.summary} maxLines={2} /> </CardLinkItem> ))} </CardCarousel> ``` ### CardCarousel Props | Prop | Type | Default | Description | | - | - | - | - | | `gap` | number \| string | `4` | Space between cards. | | `status` | `{text, icon?}` or `{text, favicon?, frame?}` | — | A header line above the carousel. | | `theme` | `light` \| `dark` | the chat's theme | Forces a color theme for the carousel. | ### CardLinkItem Props | Prop | Type | Default | Description | | - | - | - | - | | `href` | string | — | The page the card opens in a new tab. Only `https:`, `mailto:` and `tel:` links work. | | `hrefLabel` | string | `Go to article` | Accessible name of the link, read by screen readers. | | `padding` | number \| string \| object | `4` | Inner spacing. | | `background` | color | — | Background color. | ## Stack An invisible wrapper that holds a [state](/docs/developer-guides/widgets/states): a group of elements shown or hidden together. A `Stack` draws nothing of its own; its children appear in place of it. Inside a `ListView`, a `Stack` can wrap `ListViewItem` rows. ```jsx <Stack widgetStateName="Delivered" visible={{ "$state": "/status", "eq": "Delivered" }}> <Text value="Your order has arrived." /> </Stack> ``` ### Props | Prop | Type | Default | Description | | - | - | - | - | | `widgetStateName` | string | — | The state's name in the **States** tab. | | `visible` | boolean \| condition | `true` | When the group shows. The **States** tab writes this for you. | > [!TIP] > > You rarely write `Stack` by hand. Add and edit states in the [States](/docs/developer-guides/widgets/states) tab. ## Next steps > [card] Text | /docs/developer-guides/widgets/components/text | Titles, body text, captions, labels and Markdown. > [card] Form Inputs | /docs/developer-guides/widgets/components/form-inputs | Collect input with fields, dropdowns, dates and choices.