Master Detail
A list beside the record it opens, one pane at a time with a Back step when the element is narrow.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
open | boolean | false | The detail is showing. The app sets it when the user picks a record; the element clears it on Back, Escape (overlay) and the backdrop. |
breakpoint | number | 720 | Width of the element, in pixels, from which master and detail sit side by side. |
collapse | MasterDetailCollapse | stack | Layout below breakpoint: stack shows one pane at a time, overlay slides the detail over the master. |
detail-label | string | — | Accessible name of the detail pane. Defaults to "Details" in the nearest lang. |
back-label | string | — | Text of the built-in Back button. Defaults to "Back" in the nearest lang. |
Slots
| Name | Description |
|---|---|
master | The list: a c2-list, c2-table, c2-tree, anything. Fills the master pane, which scrolls. |
detail | The open record. Shown in the detail pane while open is true. |
placeholder | Shown in the detail pane in the split layout while nothing is open; hidden in the other two. |
toolbar | Extra content after the Back button in the stack and overlay layouts (a title, actions). |
back-icon | Replaces the chevron of the Back button. Mirrored in a right-to-left context. |
Events
| Name | Type | Description |
|---|---|---|
layout-change | CustomEvent<{ layout: 'split' | 'stack' | 'overlay' }> | Fired when the element's width crosses breakpoint or collapse changes, after the first measurement. Does not bubble. |
close-request | CustomEvent<{ reason: 'back' | 'escape' | 'backdrop' }> | Fired when the user asks to close the open detail, before open turns false. Cancelable: preventDefault() keeps it open (unsaved changes). Not fired by close() or by setting open. Does not bubble. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
layout | Grid holding the panes. |
master | Pane wrapping the master slot; scrolls its content. |
detail | Pane holding the toolbar and the detail slot; a region named by detail-label, a dialog in the overlay layout. |
body | Scrolling box wrapping the detail slot, under the toolbar. |
toolbar | Bar at the top of the detail in the stack and overlay layouts, wrapping the Back button and the toolbar slot. |
back | The built-in Back button. |
placeholder | Region of the detail column wrapping the placeholder slot. |
backdrop | Shade over the master while the detail is open in the overlay layout. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-master-detail--transition-duration | time | 280ms | Slide of the detail in the stack and overlay layouts. Reduced motion turns it off. |
--c2-master-detail__master--width | pixel | 320px | Width of the master column in the split layout. |
--c2-master-detail__master--background | background | transparent | |
--c2-master-detail__detail--background | background | #ffffff | Opaque by default: in the stack and overlay layouts the detail slides over the master. |
--c2-master-detail__detail--color | color | #18181b | |
--c2-master-detail__divider--border | border | 1px solid #e4e4e7 | Line between the panes in the split layout. |
--c2-master-detail__pane--overflow | overflow | auto | Overflow of the master pane and of the detail body. |
--c2-master-detail__placeholder--color | color | #71717a | |
--c2-master-detail__placeholder--background | background | transparent | |
--c2-master-detail__placeholder--padding | pixel | 24px | |
--c2-master-detail__overlay--width | pixel | 420px | Width of the detail in the overlay layout; never wider than the host. |
--c2-master-detail__overlay--box-shadow | shadow | 0 24px 60px rgba(0, 0, 0, 0.25) | Shadow of the detail in the overlay layout. |
--c2-master-detail__backdrop--background | background | rgba(9, 9, 11, 0.45) | |
--c2-master-detail__toolbar--display | display | flex | none removes the bar, for a detail that renders its own master-detail-back button. |
--c2-master-detail__toolbar--min-height | pixel | 44px | |
--c2-master-detail__toolbar--padding | pixel | 4px 8px | |
--c2-master-detail__toolbar--gap | pixel | 8px | |
--c2-master-detail__toolbar--border-bottom | border | 1px solid #e4e4e7 | |
--c2-master-detail__toolbar--background | background | transparent | |
--c2-master-detail__back--height | pixel | 36px | |
--c2-master-detail__back--padding | pixel | 0 12px 0 6px | |
--c2-master-detail__back--gap | pixel | 4px | |
--c2-master-detail__back--icon-size | pixel | 20px | |
--c2-master-detail__back--color | color | rgb(2, 101, 220) | |
--c2-master-detail__back--background | background | transparent | |
--c2-master-detail__back--font-size | length | 14px | |
--c2-master-detail__back--font-weight | number | 500 | |
--c2-master-detail__back--border-radius | border-radius | 6px | |
--c2-master-detail__back__hover--background | background | #f4f4f5 | |
--c2-master-detail__back__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under master-detail, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
back | Back | — |
details | Details | — |