Skip to content

MasterDetail ​

A list beside the detail of its picked item, for a settings pane of many things of one kind: accounts, devices. Each side scrolls on its own.

tsx
import { DetailHeader, MasterDetail, MasterItem } from '@adecore/ui/settings';
tsx
import { Button, Icon } from '@adecore/ui';
import { DetailHeader, MasterDetail, MasterItem, SettingsRow, SettingsSection } from '@adecore/ui/settings';
import { Laptop, Smartphone, Trash } from 'lucide-react';
import { useState } from 'react';

const DEVICES = [
    { id: 'laptop', name: 'Work laptop', kind: 'macOS', icon: Laptop },
    { id: 'phone', name: 'Phone', kind: 'iOS', icon: Smartphone }
];

export default function MasterDetailDemo() {
    const [picked, setPicked] = useState('laptop');
    const device = DEVICES.find((entry) => entry.id === picked)!;

    return (
        <div className="flex h-80 w-full flex-col overflow-hidden rounded-lg border border-border bg-surface">
            <MasterDetail
                listWidth={280}
                listLabel="Devices"
                list={DEVICES.map((entry) => (
                    <MasterItem key={entry.id} selected={picked === entry.id} onSelect={() => setPicked(entry.id)}>
                        <Icon icon={entry.icon} className="text-text-muted" />
                        {entry.name}
                    </MasterItem>
                ))}
                detail={
                    <>
                        <DetailHeader
                            mark={
                                <span className="grid size-10 place-items-center rounded-lg bg-surface-sunken text-text-muted">
                                    <Icon icon={device.icon} size={20} />
                                </span>
                            }
                            title={device.name}
                            subtitle={<>{device.kind}, signed in</>}
                            actions={
                                <Button size="sm" variant="danger-outline">
                                    <Icon icon={Trash} size={14} />
                                    Remove
                                </Button>
                            }
                        />
                        <SettingsSection>
                            <SettingsRow label="Last seen" control={<span className="text-xs text-text-muted">Today</span>} />
                        </SettingsSection>
                    </>
                }
            />
        </div>
    );
}

In a SettingsDialog, use a split section for the full height. Under 640 pixels wide the list stacks above the detail.

Parts ​

MasterDetail takes the list, listWidth, a listLabel for screen readers, and the detail.

MasterItem is one list row, a button with aria-current when selected.

DetailHeader heads a detail: a mark (logo or icon tile), the title, a subtitle and actions on the right.

Props ​

ComponentPropTypeDefault
MasterDetaillistReactNodeRequired.
listWidth280 | 320 | 340Required. In pixels.
listLabelstringRequired.
detailReactNodeRequired.
MasterItemselectedbooleanRequired.
onSelect() => voidRequired.
childrenReactNodeRequired.
DetailHeadermarkReactNodeRequired.
titlestringRequired.
subtitleReactNodeRequired.
actionsReactNode

All three take className and ref. MasterDetailProps, MasterItemProps and DetailHeaderProps are exported types.

Licenses and third-party notices are listed in each package.