Composition recipes
Practical patterns for combining Rad UI primitives into common product UI. Each recipe names who owns state and the minimum anatomy required for accessible behavior.
Confirm destructive action
Components: AlertDialog
State owner: parent (open / onOpenChange or uncontrolled trigger)
Keep title and description in the content layer so screen readers announce purpose before action buttons.
Settings panel with sections
Components: Tabs + form controls
State owner: Tabs for active section; each field manages its own value
Mount heavy panel content inside the active Tabs.Content only when panels are large.
Command palette
Components: Dialog + Command
State owner: dialog open; command value for selection
Trap focus inside the dialog; return focus to the opener when the palette closes.
Form field with label and error
Components: Field + TextArea (or any control)
State owner: Field (validation), or your form for server errors
Field links the label, help text and error to the control and sets aria-invalid, so there are no ids to wire by hand. See Forms & Validation.
One dialog for many rows
Components: Dialog with a handle
State owner: the handle (Dialog.createHandle())
One Root serves every row, and focus returns to the row's button on close. Popover supports handles the same way and anchors to whichever trigger opened it.
Nested disclosure
Components: Accordion inside Card
State owner: Accordion (type, value, onValueChange)
Use accordion for FAQ-style content inside a card shell. Avoid nesting multiple roving-focus containers (menus inside accordion headers) without testing keyboard order.
asChild hands over semantics
asChild renders a part as your own element instead of its default one: a Trigger around your button component, a Field.Control on a TextArea. It's how you compose without the library anticipating every combination.
The trade-off: the part's behaviour and ARIA move onto your child. A Dialog.Trigger asChild makes your element the dialog's trigger (aria-haspopup, aria-expanded, click to open); a Button asChild around a <span> gives it role="button", focus and Enter/Space activation. Rad UI doesn't second-guess the element you pass, so check the result:
- Use
asChildto put a part's behaviour on an element that should have that role. - Don't use it to borrow a part's look for an element with a different role. A link that looks like a button should stay a link;
Button asChildaround an<a href>(or a routerLink) keeps link semantics for exactly this reason. - When
asChildchanges the element type, check the accessibility tree or a screen reader.
Recipe checklist
- Named which component owns open/selected/value state
- Included required title/description parts for modal patterns
- Verified keyboard and focus behavior manually
- Used per-component imports (
@radui/ui/Component)