Skip to content

The open alternative to Salesforce, designed for AI.

Document Twenty UI anatomy and composition (#26066)

Raphaël Bosi3627c6b7a78a
diff --git a/packages/twenty-docs/ui/primitives/input/field.mdx b/packages/twenty-docs/ui/primitives/input/field.mdx
index a604b6ee36f..b3fe499708d 100644
--- a/packages/twenty-docs/ui/primitives/input/field.mdx
+++ b/packages/twenty-docs/ui/primitives/input/field.mdx
@@ -15,6 +15,30 @@ Use `Field` to group one control with its accessible label and helper text. Comp
height={240}
/>
+## Anatomy
+
+Place one control and its supporting parts inside `Field.Root`. This tree shows a field built with the styled `Input` component.
+
+```text
+Field.Root
+├── Field.Label
+├── Input
+├── Field.Description
+└── Field.Error
+```
+
+| Part | Requirement | Purpose |
+| ------------------------------------- | ------------------- | ---------------------------------------------------------------------------- |
+| `Root` | Required | Shares the name, disabled state, and validation with the control. |
+| `Label` | Recommended | Supplies a visible, associated label. An accessible name is always required. |
+| `Input` or another integrated control | Required | Receives user input and connects to the field. |
+| `Control` | Alternative control | Provides an unstyled input when you do not use an integrated control. |
+| `Description` | Optional | Adds persistent helper text associated with the control. |
+| `Error` | Optional | Shows feedback for a matching validation state. |
+| `Validity` | Optional | Exposes validity through a children render function. |
+
+`Input` and `Textarea` already integrate with the field. Place them directly inside `Root`; they supply the control behavior themselves. Compound controls such as [Select](/ui/primitives/input/select#compose-with-a-field) keep their own root and parts inside the field.
+
## Labeled control
```tsx
@@ -53,17 +77,6 @@ export const UsernameField = ({ error }: UsernameFieldProps) => (
);
```
-## Parts
-
-| Part | Purpose |
-| ------------- | ---------------------------------------------------- |
-| `Root` | Shares field state and validation with the control. |
-| `Label` | Names the control. |
-| `Control` | Provides an unstyled input with field integration. |
-| `Description` | Adds persistent helper text. |
-| `Error` | Shows feedback for a matching validation state. |
-| `Validity` | Exposes validity through a children render function. |
-
Keep error messages actionable and provide a visible label even when the control has a placeholder.
## Props
diff --git a/packages/twenty-docs/ui/primitives/input/input-group.mdx b/packages/twenty-docs/ui/primitives/input/input-group.mdx
index 4c745357820..a8283dcdbab 100644
--- a/packages/twenty-docs/ui/primitives/input/input-group.mdx
+++ b/packages/twenty-docs/ui/primitives/input/input-group.mdx
@@ -15,6 +15,28 @@ import InputGroupReference from '/snippets/ui/generated/input/input-group.mdx';
height={240}
/>
+## Anatomy
+
+Place the input inside `InputGroup` and keep field labels and messages outside the shared border.
+
+```text
+Field.Root
+├── Field.Label
+├── InputGroup
+│ └── Input
+└── Field.Description
+```
+
+| Part or slot | Requirement | Purpose |
+| --------------------------------------------- | -------------------- | ------------------------------------------------------------------------ |
+| `InputGroup` | Required | Supplies the shared border, layout, and size. |
+| `Input` as `children` | Required | Owns the input value, native attributes, and editing behavior. |
+| `startElement` | Optional prop | Adds a prefix, icon, or other content before the input. |
+| `endElement` | Optional prop | Adds a suffix or action after the input. |
+| `Field.Root`, `Label`, `Description`, `Error` | Optional composition | Associates a label, helper text, and validation feedback with the input. |
+
+`startElement` and `endElement` are React node props, not separate components. `InputGroup` does not supply a label or manage validation. Give the input an accessible name, either through `Field.Label` or its own labeling attributes.
+
## Prefix and suffix
```tsx
@@ -37,7 +59,7 @@ export const WebsiteField = () => (
```tsx
import { useState } from 'react';
-import { Field, Input, InputGroup } from 'twenty-ui/primitives/input';
+import { Button, Field, Input, InputGroup } from 'twenty-ui/primitives/input';
export const PasswordField = () => {
const [visible, setVisible] = useState(false);
@@ -47,14 +69,14 @@ export const PasswordField = () => {
<Field.Label>Password</Field.Label>
<InputGroup
endElement={
- <button
+ <Button
type="button"
- aria-label="Show password"
- aria-pressed={visible}
+ title={visible ? 'Hide' : 'Show'}
+ ariaLabel={visible ? 'Hide password' : 'Show password'}
+ variant="tertiary"
+ size="small"
onClick={() => setVisible(!visible)}
- >
- Show
- </button>
+ />
}
>
<Input
diff --git a/packages/twenty-docs/ui/primitives/input/radio-group.mdx b/packages/twenty-docs/ui/primitives/input/radio-group.mdx
index 904ca1f1e70..388decc53c6 100644
--- a/packages/twenty-docs/ui/primitives/input/radio-group.mdx
+++ b/packages/twenty-docs/ui/primitives/input/radio-group.mdx
@@ -15,6 +15,29 @@ import RadioGroupReference from '/snippets/ui/generated/input/radio-group.mdx';
height={240}
/>
+## Anatomy
+
+Put each `Radio` inside the group and associate it with a label. `RadioGroup` and `Radio` are separate exports.
+
+```text
+fieldset
+├── legend
+└── RadioGroup
+ ├── label
+ │ └── Radio
+ └── label
+ └── Radio
+```
+
+| Part | Requirement | Purpose |
+| -------------------- | --------------------------- | ---------------------------------------------------------- |
+| `RadioGroup` | Required | Owns selection, keyboard navigation, and form integration. |
+| `Radio` | One per option | Supplies an option with a distinct `value`. |
+| `label` | Recommended for each option | Provides a visible, clickable name for its radio. |
+| `fieldset`, `legend` | Optional grouping | Groups related controls under a visible heading. |
+
+Give the group its own accessible name using `aria-label` or `aria-labelledby`. In the examples below, `aria-labelledby` connects the group to the legend. Each radio also needs its own name. Put selection props on `RadioGroup` and option values on `Radio`.
+
## Uncontrolled state
Use `defaultValue` to set the initial billing frequency. The group owns subsequent changes.
diff --git a/packages/twenty-docs/ui/primitives/input/select.mdx b/packages/twenty-docs/ui/primitives/input/select.mdx
index cc23a912fca..a7bf894561b 100644
--- a/packages/twenty-docs/ui/primitives/input/select.mdx
+++ b/packages/twenty-docs/ui/primitives/input/select.mdx
@@ -15,6 +15,30 @@ Use `Select` for a form value chosen from a list. Use [Menu](/ui/primitives/surf
height={400}
/>
+## Anatomy
+
+Keep the trigger and popup inside the same `Select.Root`. Put option labels directly inside `Select.Item`.
+
+```text
+Select.Root
+├── Select.Trigger
+│ └── Select.Value
+└── Select.Popup
+ └── Select.Item
+```
+
+| Part | Requirement | Purpose |
+| --------------------- | ----------------------------------- | ------------------------------------------------------------------------------------ |
+| `Root` | Required | Owns selection, open state, and form integration. |
+| `Trigger` | Required for a trigger-based select | Opens the list and displays its current value. |
+| `Value` | Optional | Renders the selected label or a placeholder; you can provide custom trigger content. |
+| `Popup` | Required for the option list | Renders the positioned, portaled list. |
+| `Item` | One per option | Provides selection behavior and an option label. |
+| `Group`, `GroupLabel` | Optional | Group related options under a label. |
+| `Separator` | Optional | Separates groups visually. |
+
+Twenty UI includes the chevron in `Trigger`, the option text and checkmark in `Item`, and the portal and positioner in `Popup`. Compose these public parts directly; placement and portal options belong on `Popup`.
+
## Uncontrolled state
Use `defaultValue` to set the initial priority. The select owns subsequent selection changes.
@@ -166,17 +190,44 @@ export const PrioritySelect = () => {
};
```
-## Parts and placement
-
-| Part | Purpose |
-| --------------------- | ---------------------------------------------------------- |
-| `Root` | Owns selection, open state, and form integration. |
-| `Trigger` | Opens the list and supports `sm` or `md` sizing. |
-| `Value` | Displays the selected label or a placeholder. |
-| `Popup` | Provides the portal and positioned list. |
-| `Item` | Represents an option, with optional icons and description. |
-| `Group`, `GroupLabel` | Group related options under an accessible label. |
-| `Separator` | Separates groups visually. |
+## Compose with a field
+
+Wrap the select in `Field.Root` to associate its trigger with a visible label and helper text. The field handles labeling and validation; the select keeps its own selection and popup state.
+
+```tsx
+import { Field, Select } from 'twenty-ui/primitives/input';
+
+const PRIORITIES = [
+ { value: 'low', label: 'Low' },
+ { value: 'normal', label: 'Normal' },
+ { value: 'high', label: 'High' },
+];
+
+export const PriorityField = () => (
+ <Field.Root name="priority">
+ <Field.Label>Priority</Field.Label>
+ <Select.Root name="priority" defaultValue="normal" items={PRIORITIES}>
+ <Select.Trigger>
+ <Select.Value />
+ </Select.Trigger>
+ <Select.Popup>
+ {PRIORITIES.map(({ value, label }) => (
+ <Select.Item key={value} value={value}>
+ {label}
+ </Select.Item>
+ ))}
+ </Select.Popup>
+ </Select.Root>
+ <Field.Description>
+ Choose how soon this record needs attention.
+ </Field.Description>
+ </Field.Root>
+);
+```
+
+## Placement and keyboard
+
+Set `size="sm"` or `size="md"` on `Trigger`. Customize option content with `Item.startIcon`, `Item.endIcon`, and `Item.description` while keeping the option's label in its children.
`Popup` defaults to `side="bottom"`, `align="start"`, and `sideOffset={8}`. Set `alignItemWithTrigger` to align the selected option over the trigger. It uses the [theme's portal container](/ui/theming#scope-an-override) unless you provide `container`.
diff --git a/packages/twenty-docs/ui/primitives/input/slider.mdx b/packages/twenty-docs/ui/primitives/input/slider.mdx
index 3bcb5c0aeaf..a4189467a4e 100644
--- a/packages/twenty-docs/ui/primitives/input/slider.mdx
+++ b/packages/twenty-docs/ui/primitives/input/slider.mdx
@@ -15,6 +15,32 @@ import SliderReference from '/snippets/ui/generated/input/slider.mdx';
height={240}
/>
+## Anatomy
+
+Put the track and thumbs inside `Slider.Control`, which handles pointer interaction. This tree shows a single-thumb slider.
+
+```text
+Slider.Root
+├── Slider.Label
+├── Slider.Value
+└── Slider.Control
+ └── Slider.Track
+ ├── Slider.Indicator
+ └── Slider.Thumb
+```
+
+| Part | Requirement | Purpose |
+| ----------- | ----------------------------- | --------------------------------------------------------------- |
+| `Root` | Required | Owns the value, bounds, step, and orientation. |
+| `Control` | Required | Handles pointer interaction and positions the thumbs. |
+| `Track` | Required for the styled track | Shows the full value range. |
+| `Thumb` | One per adjustable value | Provides a focusable handle with keyboard interaction. |
+| `Label` | Recommended | Supplies a visible label; every thumb needs an accessible name. |
+| `Value` | Optional | Displays the current numeric value. |
+| `Indicator` | Optional | Shows the selected portion of the track. |
+
+For a range, add a thumb for each value with its matching `index` and a distinct accessible name. Labels and numeric output stay outside `Control`, so they do not become part of the draggable area.
+
## Uncontrolled state
Use `defaultValue` to set the initial volume. The slider owns subsequent changes.
@@ -100,17 +126,7 @@ Give range thumbs distinct accessible names and an `index` corresponding to thei
To control a range, store the array in React state and pass it through `value` and `onValueChange`, just as for a single value.
-## Parts and keyboard
-
-| Part | Purpose |
-| ----------- | ---------------------------------------------- |
-| `Root` | Owns the value, bounds, step, and orientation. |
-| `Label` | Names the slider. |
-| `Value` | Displays the current value. |
-| `Control` | Handles pointer interaction. |
-| `Track` | Shows the full value range. |
-| `Indicator` | Shows the selected portion of the track. |
-| `Thumb` | Provides a focusable handle for one value. |
+## Keyboard and appearance
Arrow keys adjust a focused thumb by a step. Home and End move it toward the bounds while respecting range constraints. `orientation="vertical"` changes the layout and keyboard direction. Use `disabled` on `Root` to prevent changes.
diff --git a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
index c4c8fca34b5..cfc4b22b2e8 100644
--- a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
+++ b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
@@ -15,6 +15,29 @@ import ListItemReference from '/snippets/ui/generated/navigation/list-item.mdx';
height={240}
/>
+## Anatomy
+
+`ListItem` exposes content slots through props. These slots arrange content inside one row; they are not separately exported components.
+
+```text
+ListItem
+├── startIcon
+├── children
+├── description
+├── actions
+└── endIcon
+```
+
+| Slot | Requirement | Purpose |
+| ------------------------------------ | -------------------------------- | ------------------------------------------------------------------------------- |
+| `children` | Required for a visible row label | Supplies the main text. |
+| `startIcon`, `endIcon` | Optional | Add supporting icons at either end of the row content. |
+| `description` | Optional | Adds supporting text inline or at the end, according to `descriptionPlacement`. |
+| `actions` | Optional | Adds trailing content, such as a separately focusable action. |
+| `indicator`, `hotkeys`, `hasSubmenu` | Optional | Configure built-in selection marks, shortcut hints, and the submenu indicator. |
+
+The row supplies layout. Use `render` to choose its element and semantics. For a row with independent action buttons, keep the row itself non-interactive so those buttons remain separate controls.
+
## Action row
```tsx
@@ -65,6 +88,31 @@ export const ShowArchivedToggle = () => {
Use `startIcon` and `endIcon` for icons, `description` for supporting text, `actions` for trailing content, and `hasSubmenu` for a submenu indicator. `descriptionPlacement` accepts `inline` or `end`. `color="danger"` styles a destructive action. Avoid nesting interactive controls inside a row rendered as a button.
+```tsx
+import { Button } from 'twenty-ui/primitives/input';
+import { ListItem } from 'twenty-ui/primitives/navigation';
+
+type ContactRowProps = { onOpen: () => void };
+
+export const ContactRow = ({ onOpen }: ContactRowProps) => (
+ <ListItem
+ description="Account owner"
+ actions={
+ <Button
+ type="button"
+ title="Open"
+ ariaLabel="Open Alex Morgan's profile"
+ variant="tertiary"
+ size="small"
+ onClick={onOpen}
+ />
+ }
+ >
+ Alex Morgan
+ </ListItem>
+);
+```
+
## Props
The reference is generated from the public component types. Native attributes, including accessible names and event handlers, are also accepted on parts that render elements.
diff --git a/packages/twenty-docs/ui/primitives/navigation/tabs.mdx b/packages/twenty-docs/ui/primitives/navigation/tabs.mdx
index bd3102871b6..574b46e0611 100644
--- a/packages/twenty-docs/ui/primitives/navigation/tabs.mdx
+++ b/packages/twenty-docs/ui/primitives/navigation/tabs.mdx
@@ -15,6 +15,28 @@ import TabsReference from '/snippets/ui/generated/navigation/tabs.mdx';
height={240}
/>
+## Anatomy
+
+Place tabs inside `Tabs.List` and their panels alongside the list, all within the same `Tabs.Root`.
+
+```text
+Tabs.Root
+├── Tabs.List
+│ ├── Tabs.Tab
+│ └── Tabs.Tab
+├── Tabs.Panel
+└── Tabs.Panel
+```
+
+| Part | Requirement | Purpose |
+| ------- | -------------------- | -------------------------------------------------------------------------- |
+| `Root` | Required | Owns the active value and orientation. |
+| `List` | Required | Groups the tabs and supplies keyboard navigation and the active indicator. |
+| `Tab` | One per panel | Activates the panel with the same `value`. |
+| `Panel` | One per content view | Displays its content when its `value` is active. |
+
+Give the list an accessible name and match each selectable tab's `value` to its panel's `value`. Twenty UI includes the active indicator in `List`. Use `Tab.startIcon` and `Tab.badge` for optional supporting content while keeping the tab label in its children.
+
## Uncontrolled state
Use `defaultValue` to set the initial active tab. The tabs own subsequent selection changes.
@@ -93,16 +115,9 @@ export const SettingsTabs = () => {
With `activateOnFocus={false}`, arrow keys move focus and Enter or Space activates the focused tab. `loopFocus` defaults to `true`. Disabled tabs are skipped. Use `orientation="vertical"` on `Root` for vertical navigation.
-## Parts
-
-| Part | Purpose |
-| ------- | ---------------------------------------------------------- |
-| `Root` | Owns the active value and orientation. |
-| `List` | Labels and groups the tabs; includes the active indicator. |
-| `Tab` | Selects its matching panel. |
-| `Panel` | Displays content for one value. |
+## Panel lifetime
-Use `keepMounted` on a panel when its contents must remain mounted while inactive. Give the list an accessible name that describes the set of panels.
+Use `keepMounted` on a panel when its contents must remain mounted while inactive.
## Props
diff --git a/packages/twenty-docs/ui/primitives/overview.mdx b/packages/twenty-docs/ui/primitives/overview.mdx
index ee5245085e9..0b7544a80c9 100644
--- a/packages/twenty-docs/ui/primitives/overview.mdx
+++ b/packages/twenty-docs/ui/primitives/overview.mdx
@@ -28,6 +28,60 @@ Some components have more than one independent state. For example, [Select](/ui/
State belongs to the part that manages the interaction. Configure radio selection on [RadioGroup](/ui/primitives/input/radio-group), not on each Radio. Display components such as Text do not have a controlled or uncontrolled mode. [Toast](/ui/primitives/feedback/toast) delegates its visibility and removal to the application.
+## Composition
+
+Compound primitives expose parts such as `Select.Root`, `Select.Trigger`, and `Select.Popup`. Keep related parts under the same root in the component tree so they share state and accessibility relationships. Each component's anatomy section identifies the required parts and optional content.
+
+Slots such as `InputGroup.startElement` and `ListItem.actions` accept React nodes as props. They add content within a component's layout. Parts and slots are different APIs; use the names listed in the component guide.
+
+### Popup composition
+
+Twenty UI packages the supporting overlay elements inside each public `Popup` part:
+
+| Component | Included in `Popup` | Configure on `Popup` |
+| ------------- | -------------------------------------- | -------------------------------------------------------- |
+| `Select` | Portal and positioner | Placement, anchor, and portal container |
+| `Menu` | Portal and positioner | Placement, anchor, portal container, and mounting |
+| `Popover` | Portal, positioner, and optional arrow | Placement, anchor, portal container, mounting, and arrow |
+| `AlertDialog` | Portal, backdrop, and viewport | Size, portal container, mounting, and focus |
+
+Place content directly inside these popup parts. Their portal may move the rendered DOM to another container while preserving the component hierarchy and context. See [theming](/ui/theming#scope-an-override) for scoped portal containers.
+
+### Custom components
+
+For parts that support `render`, pass a compatible element or component to replace the default element. For example, `Popover.Trigger` can use a Twenty UI `Button` while retaining its trigger behavior.
+
+A custom wrapper must pass the supplied props and ref to the interactive element. This preserves event handlers, accessibility attributes, positioning, and focus restoration. This example forwards them through `Button`, which attaches them to its native button.
+
+```tsx
+import { type ComponentPropsWithRef } from 'react';
+import { Button } from 'twenty-ui/primitives/input';
+import { Popover } from 'twenty-ui/primitives/surfaces';
+
+type HelpButtonProps = ComponentPropsWithRef<typeof Button>;
+
+const HelpButton = ({ ref, ...props }: HelpButtonProps) => (
+ <Button {...props} ref={ref} variant="secondary" />
+);
+
+export const ImportHelp = () => (
+ <Popover.Root>
+ <Popover.Trigger render={<HelpButton title="Import help" />} />
+ <Popover.Popup>
+ <Popover.Title>Import a CSV file</Popover.Title>
+ <Popover.Description>
+ Use a header row to identify your columns.
+ </Popover.Description>
+ <Popover.Close render={<Button title="Got it" />} />
+ </Popover.Popup>
+ </Popover.Root>
+);
+```
+
+Pass the button through `render` and keep each action as a single interactive control. Preserve the handlers and ref supplied to your wrapper when adding your own behavior. The ref must reach the element that receives focus.
+
+Use a native button for button-like parts. On parts that expose `nativeButton`, set `nativeButton={false}` only when the rendered element is not a native button. A custom component that ultimately renders a button, such as `HelpButton`, keeps the default button behavior.
+
## Browse primitives
Each page includes usage examples, interaction guidance, and a generated API reference.
diff --git a/packages/twenty-docs/ui/primitives/surfaces/alert-dialog.mdx b/packages/twenty-docs/ui/primitives/surfaces/alert-dialog.mdx
index 7159ca410cd..7414d5d5c8a 100644
--- a/packages/twenty-docs/ui/primitives/surfaces/alert-dialog.mdx
+++ b/packages/twenty-docs/ui/primitives/surfaces/alert-dialog.mdx
@@ -15,6 +15,37 @@ Use `AlertDialog` for a decision that interrupts the current workflow, such as c
height={440}
/>
+## Anatomy
+
+Keep the trigger and popup inside `AlertDialog.Root`. This tree shows the recommended layout for a confirmation dialog.
+
+```text
+AlertDialog.Root
+├── AlertDialog.Trigger
+└── AlertDialog.Popup
+ ├── AlertDialog.Header
+ │ ├── AlertDialog.Title
+ │ └── AlertDialog.Description
+ ├── AlertDialog.Body
+ └── AlertDialog.Footer
+ ├── AlertDialog.Close
+ └── Confirmation action
+```
+
+| Part | Requirement | Purpose |
+| -------------------------- | --------------------------------------------- | ------------------------------------------------------------------------ |
+| `Root` | Required | Coordinates open state and modal behavior. |
+| `Trigger` | Optional for a programmatically opened dialog | Opens the dialog and provides a return focus target. |
+| `Popup` | Required | Renders the modal content with focus management. |
+| `Title` | Recommended | Supplies the visible dialog name. An accessible name is always required. |
+| `Description` | Recommended for a confirmation | Explains the decision and its consequences. |
+| `Header`, `Body`, `Footer` | Optional layout parts | Arrange headings, additional content, and actions. |
+| `Close` | Recommended for cancellation | Supplies an explicit close action. |
+
+`Popup` includes the portal, backdrop, and viewport. Put content directly inside it and set `size`, `container`, and focus props on `Popup`. `Header`, `Body`, and `Footer` arrange content; `Title` and `Description` provide the accessible relationships.
+
+The confirmation action is application content, not an exported part. Use `Close` with a synchronous handler or a `Button` with controlled open state for asynchronous confirmation.
+
## Uncontrolled state
Use `defaultOpen` to set the initial visibility. The dialog owns subsequent changes from its trigger, close controls, and dismissal interactions.
@@ -80,18 +111,45 @@ export const DeleteConfirmation = ({ onDelete }: DeleteConfirmationProps) => {
For asynchronous confirmation, use a `Button` with your action handler instead of `AlertDialog.Close`. Keep `open` true while the action is pending, call `setOpen(false)` after it succeeds, and show an error inside the dialog if it fails.
-## Parts and sizing
-
-| Part | Purpose |
-| ---------------------- | ------------------------------------------------------------ |
-| `Root` | Coordinates open state and modal behavior. |
-| `Trigger` | Opens the dialog. |
-| `Popup` | Includes the portal, backdrop, viewport, and dialog content. |
-| `Title`, `Description` | Name the dialog and explain the decision. |
-| `Header` | Groups the title and description. |
-| `Body` | Holds optional additional content. |
-| `Footer` | Groups confirmation and cancellation actions. |
-| `Close` | Closes the dialog; `onClick` can run a synchronous action. |
+## Compose with buttons
+
+Use `render` to give the trigger and close controls Twenty UI button styling. The dialog parts supply their interaction handlers and refs to the buttons.
+
+```tsx
+import { Button } from 'twenty-ui/primitives/input';
+import { AlertDialog } from 'twenty-ui/primitives/surfaces';
+
+type DeleteConfirmationProps = { onDelete: () => void };
+
+export const DeleteConfirmation = ({ onDelete }: DeleteConfirmationProps) => (
+ <AlertDialog.Root>
+ <AlertDialog.Trigger
+ render={<Button title="Delete record" accent="danger" />}
+ />
+ <AlertDialog.Popup>
+ <AlertDialog.Header>
+ <AlertDialog.Title>Delete this record?</AlertDialog.Title>
+ <AlertDialog.Description>
+ This action cannot be undone.
+ </AlertDialog.Description>
+ </AlertDialog.Header>
+ <AlertDialog.Footer>
+ <AlertDialog.Close
+ render={<Button title="Cancel" variant="secondary" />}
+ />
+ <AlertDialog.Close
+ onClick={onDelete}
+ render={<Button title="Delete" accent="danger" />}
+ />
+ </AlertDialog.Footer>
+ </AlertDialog.Popup>
+ </AlertDialog.Root>
+);
+```
+
+Keep each action as a single interactive control. If you wrap `Button` in your own component, [forward the supplied props and ref](/ui/primitives/overview#custom-components).
+
+## Sizing and portals
`Popup.size` defaults to `md`; see the reference for supported sizes. Use `container` to override the theme's portal container and `keepMounted` to retain mounted content when closed.
diff --git a/packages/twenty-docs/ui/primitives/surfaces/menu.mdx b/packages/twenty-docs/ui/primitives/surfaces/menu.mdx
index d0b85ec4f14..943e2db153a 100644
--- a/packages/twenty-docs/ui/primitives/surfaces/menu.mdx
+++ b/packages/twenty-docs/ui/primitives/surfaces/menu.mdx
@@ -15,6 +15,33 @@ Use `Menu` for actions opened from a trigger. Its items supply keyboard navigati
height={440}
/>
+## Anatomy
+
+Keep the trigger and popup inside the same `Menu.Root`. Put action or selection items inside the popup.
+
+```text
+Menu.Root
+├── Menu.Trigger
+└── Menu.Popup
+ ├── Menu.Item
+ ├── Menu.Separator
+ └── Menu.Item
+```
+
+| Part | Requirement | Purpose |
+| ------------------------------- | --------------------------------- | -------------------------------------------------------------------------- |
+| `Root` | Required | Owns open state and coordinates menu interaction. |
+| `Trigger` | Required for a trigger-based menu | Opens the menu and provides its accessible name. |
+| `Popup` | Required | Renders the positioned, portaled menu with keyboard navigation. |
+| `Item` | One per action | Runs a command when selected. |
+| `CheckboxItem` | Optional | Toggles an independent boolean option. |
+| `RadioGroup`, `RadioItem` | Optional | Coordinate mutually exclusive options. Put radio items inside their group. |
+| `Group`, `GroupLabel` | Optional | Group related items under a label. |
+| `Separator` | Optional | Separates groups visually. |
+| `SubmenuRoot`, `SubmenuTrigger` | Optional | Add a nested menu with its own popup. |
+
+`Popup` includes the portal and positioner. Menu items include the row layout and selection indicators. Supply labels as children and use `startIcon`, `endIcon`, and `description` for supporting content.
+
## Uncontrolled state
Use `defaultOpen` to set the initial visibility. The menu owns subsequent changes from its trigger, item selection, and dismissal interactions.
@@ -78,6 +105,18 @@ export const RecordMenu = ({ onDuplicate, onDelete }: RecordMenuProps) => {
Item selection is independent of popup visibility. Checkbox items use `defaultChecked` or `checked` with `onCheckedChange`. Radio groups use `defaultValue` or `value` with `onValueChange`.
+For a submenu, place `SubmenuRoot` inside the parent popup, with its own trigger and popup. Each nested popup retains its own positioning and keyboard behavior.
+
+```text
+Menu.Popup
+└── Menu.SubmenuRoot
+ ├── Menu.SubmenuTrigger
+ └── Menu.Popup
+ └── Menu.RadioGroup
+ ├── Menu.RadioItem
+ └── Menu.RadioItem
+```
+
### Uncontrolled item state
Each checkbox item and radio group owns its selection. Both the menu and submenu also manage their own visibility.
@@ -147,17 +186,38 @@ export const ViewMenu = () => {
Checkbox and radio items keep the popup open by default so users can adjust options. Use `closeOnClick` to change that behavior. Nest a `SubmenuRoot`, `SubmenuTrigger`, and `Popup` inside a parent popup for submenus. Each `SubmenuRoot` has its own `defaultOpen`, `open`, and `onOpenChange` props, independent of the parent menu.
-## Parts and interaction
-
-| Part | Purpose |
-| ------------------------------- | -------------------------------------------- |
-| `Root`, `Trigger`, `Popup` | Own, open, and position the menu. |
-| `Item` | Runs an action. |
-| `CheckboxItem` | Toggles an independent boolean option. |
-| `RadioGroup`, `RadioItem` | Coordinate mutually exclusive options. |
-| `Group`, `GroupLabel` | Label a group of related items. |
-| `Separator` | Separates groups. |
-| `SubmenuRoot`, `SubmenuTrigger` | Coordinate a nested menu with its own popup. |
+## Compose a trigger
+
+Use `render` to make a Twenty UI `Button` the trigger. The menu supplies the button's activation handlers and accessibility attributes.
+
+```tsx
+import { IconCopy, IconTrash } from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
+import { Menu } from 'twenty-ui/primitives/surfaces';
+
+type RecordMenuProps = { onDuplicate: () => void; onDelete: () => void };
+
+export const RecordMenu = ({ onDuplicate, onDelete }: RecordMenuProps) => (
+ <Menu.Root>
+ <Menu.Trigger
+ render={<Button title="Record actions" variant="secondary" />}
+ />
+ <Menu.Popup>
+ <Menu.Item startIcon={<IconCopy />} onClick={onDuplicate}>
+ Duplicate
+ </Menu.Item>
+ <Menu.Separator />
+ <Menu.Item startIcon={<IconTrash />} color="danger" onClick={onDelete}>
+ Delete
+ </Menu.Item>
+ </Menu.Popup>
+ </Menu.Root>
+);
+```
+
+Put `Button` in the trigger's `render` prop to preserve a single interactive control. For custom wrapper components, [forward the supplied props and ref](/ui/primitives/overview#custom-components).
+
+## Keyboard and placement
Arrow keys move through the items, including disabled ones, which receive focus but cannot be selected; typeahead finds items by their text. Enter or Space selects an item. Escape closes the menu and returns focus to its trigger. Use clear text labels even when items have icons.
diff --git a/packages/twenty-docs/ui/primitives/surfaces/popover.mdx b/packages/twenty-docs/ui/primitives/surfaces/popover.mdx
index 423d7d5021e..5ecf6319e68 100644
--- a/packages/twenty-docs/ui/primitives/surfaces/popover.mdx
+++ b/packages/twenty-docs/ui/primitives/surfaces/popover.mdx
@@ -15,6 +15,30 @@ Use `Popover` for contextual information or lightweight controls. `Popup` includ
height={440}
/>
+## Anatomy
+
+Keep the trigger and popup inside `Popover.Root`. The popup can contain text, form controls, and actions.
+
+```text
+Popover.Root
+├── Popover.Trigger
+└── Popover.Popup
+ ├── Popover.Title
+ ├── Popover.Description
+ └── Popover.Close
+```
+
+| Part | Requirement | Purpose |
+| ------------- | --------------------------------------- | --------------------------------------------------------------------- |
+| `Root` | Required | Coordinates open state and interactions. |
+| `Trigger` | Required for a trigger-anchored popover | Opens or closes the popup and supplies its anchor. |
+| `Popup` | Required | Renders positioned content with focus management. |
+| `Title` | Recommended | Supplies a visible popup name. An accessible name is always required. |
+| `Description` | Optional | Associates explanatory text with the popup. |
+| `Close` | Optional | Provides an explicit close action within the popup. |
+
+`Popup` includes the portal and positioner. Set `arrow` on `Popup` to add its built-in arrow. All parts share their root's context even though the popup renders in a portal; the tree describes component nesting, not the final DOM placement.
+
## Uncontrolled state
Use `defaultOpen` to set the initial visibility. The popover owns subsequent changes from its trigger, close controls, and dismissal interactions.
@@ -66,15 +90,33 @@ export const ImportHelp = () => {
`onOpenChange` receives the next boolean and event details, including changes requested by the trigger, close controls, Escape, and outside interaction.
-## Parts and placement
+## Compose with buttons
+
+Pass a Twenty UI `Button` through `render` to use it as the trigger or close control. The popover keeps its open state, keyboard behavior, and focus handling.
+
+```tsx
+import { Button } from 'twenty-ui/primitives/input';
+import { Popover } from 'twenty-ui/primitives/surfaces';
+
+export const ImportHelp = () => (
+ <Popover.Root>
+ <Popover.Trigger
+ render={<Button title="Import help" variant="secondary" />}
+ />
+ <Popover.Popup arrow>
+ <Popover.Title>Import a CSV file</Popover.Title>
+ <Popover.Description>
+ Use a header row to identify your columns.
+ </Popover.Description>
+ <Popover.Close render={<Button title="Got it" />} />
+ </Popover.Popup>
+ </Popover.Root>
+);
+```
+
+`render` composes behavior onto the supplied button. Custom wrapper components must [forward the supplied props and ref](/ui/primitives/overview#custom-components) to preserve that behavior.
-| Part | Purpose |
-| ---------------------- | -------------------------------------------------- |
-| `Root` | Coordinates open state and interactions. |
-| `Trigger` | Opens or closes the popup. |
-| `Popup` | Renders the positioned content and optional arrow. |
-| `Title`, `Description` | Name and describe the popup. |
-| `Close` | Closes the popup. |
+## Placement and focus
`Popup` defaults to `side="bottom"`, `align="center"`, and `sideOffset={8}`. Set `arrow` to show an arrow. Set `container` to override the theme's portal container; see [theming](/ui/theming).
diff --git a/packages/twenty-ui/README.md b/packages/twenty-ui/README.md
index 12eccb7019a..a9b1978bc70 100644
--- a/packages/twenty-ui/README.md
+++ b/packages/twenty-ui/README.md
@@ -81,6 +81,8 @@ Component guides belong in `packages/twenty-docs/ui/primitives`. For each statef
Explain state ownership before advanced behavior such as indeterminate selection or manual tab activation. Document independent states, such as selection and popup visibility, separately. For components that delegate state to a parent or group, explain that ownership and link to the relevant examples.
+For compound components, include an anatomy tree and identify required parts, optional parts, and elements supplied internally. Show supported composition with complete examples, use Twenty UI components for supporting controls, and explain how custom wrappers preserve props and refs. Use `text` fences for structural diagrams and `tsx` fences for runnable examples so the documentation checker validates the examples.
+
## Internal state
twenty-ui uses Base UI's store for notification state. Each `ToastProvider` creates its own store, and the toaster subscribes to the toast list. Queue rules and rendering remain owned by twenty-ui. Consumers use `useToast()` without configuring a state library.