# Layout and Grouping

Grids, cards, boxes, collapsible sections and lists. Exact props: `widgets-get-component-props`.

---

## DLayout and DLayout.Pane

A grid. `DLayout` sets the gap (`gap`, and `gapSm` … `gapXxl` per breakpoint, from 0 to 30) and optionally the number of `columns`; each `DLayout.Pane` sets its width with `cols` and `colsXs` … `colsXxl`:

```tsx
<DLayout gap={4}>
  <DLayout.Pane cols={12} colsMd={8}>
    <AccountSummary />
  </DLayout.Pane>
  <DLayout.Pane cols={12} colsMd={4}>
    <QuickActions />
  </DLayout.Pane>
</DLayout>
```

Bootstrap's grid classes (`container`, `row`, `col-*`) also work: Dynamic UI is built on Bootstrap. There are no `DRow`, `DCol` or `DContainer` components.

## DCard

A card with optional header and footer:

```tsx
<DCard>
  <DCard.Header>{t('account.title')}</DCard.Header>
  <DCard.Body>{children}</DCard.Body>
  <DCard.Footer>{actions}</DCard.Footer>
</DCard>
```

From the template's `src/app/App.tsx`:

```tsx
<DCard className="container my-md-14">
  <DCard.Body className="d-flex flex-column gap-4 p-4 p-md-14">
    {/* … */}
  </DCard.Body>
</DCard>
```

`DCard` and its parts take `children`, `className` and `style`; there are no icon or title props. Put the icon inside the header or body.

## DBox

A plain container (`children`, `className`, `style`). Use utility classes for alignment and spacing: `<DBox className="d-flex gap-3 align-items-center">`.

## DCollapse

A section that expands and collapses. `Component` is the always-visible header (required); the children are the collapsible content:

```tsx
<DCollapse Component={<span className="fw-bold">{t('details.title')}</span>} defaultCollapsed>
  {details}
</DCollapse>
```

`defaultCollapsed` is `true` by default; `onChange(value)` reports the new state; `iconOpen`/`iconClose` change the toggle icons.

## DListGroup and DListGroup.Item

```tsx
<DListGroup ariaLabel={t('entities.list.title')}>
  {entities.map((entity) => (
    <DListGroup.Item key={entity.id}>{entity.name}</DListGroup.Item>
  ))}
</DListGroup>
```

| Part | Props |
|------|-------|
| `DListGroup` | `flush`, `horizontal`, `numbered`, `as`, `ariaLabel`, `ariaLabelledBy` |
| `DListGroup.Item` | `as` (`li` by default, `a` or `button`), `action`, `active`, `disabled`, `href`, `onClick`, `color`, `iconStart`, `iconEnd`, `ariaCurrent` |

A clickable item uses `as="button"` with `onClick`, or `as="a"` with `href`. Give the list an accessible name with `ariaLabel` or `ariaLabelledBy`.

---

## Common mistakes

| Wrong | Right |
|-------|-------|
| `<DRow>`, `<DCol>`, `<DContainer>` | `DLayout` + `DLayout.Pane`, or Bootstrap's grid classes |
| `<DBox align="center" direction="row">` | `<DBox className="d-flex align-items-center">` |
| `<DCollapse collapsed={…}>` | `defaultCollapsed` + `onChange` |
| `<DCard iconStart="…">` | An icon inside `DCard.Header` or `DCard.Body` |
| `<DCardBody>` | `<DCard.Body>` (both resolve to the same component; the accessor is the documented form) |
