Panel
import * as Panel from '@dxos/react-ui/Panel';A panel is the shell of a pane: a header row, a body that takes the rest of the height, and a footer row. Layout explains how it scrolls.
import * as import Button
Button from '@dxos/react-ui/Button';import * as import Icon
Icon from '@dxos/react-ui/Icon';import * as import Layout
Layout from '@dxos/react-ui/Layout';import * as import Panel
Panel from '@dxos/react-ui/Panel';import * as import ScrollArea
ScrollArea from '@dxos/react-ui/ScrollArea';import * as import Toolbar
Toolbar from '@dxos/react-ui/Toolbar';import * as import Typography
Typography from '@dxos/react-ui/Typography';
export const const ContactsPanel: () => React.JSX.Element
ContactsPanel = () => ( <import Panel
Panel.const Root: React.ForwardRefExoticComponent<Omit<Panel.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
The plank host: fills its parent, sets data-size and a level for its subtree, and is the pane's
query container, so its header, body and footer collapse at the same pane width.
Root> <import Panel
Panel.const Header: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Header
The top row on the bar aspect, which steps off whatever level hosts the panel; it sizes to its content, so it takes
no space when empty and one block when it holds a Toolbar.Root.
Header> <import Toolbar
Toolbar.const Root: React.ForwardRefExoticComponent<Omit<Toolbar.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
role=toolbar with the roving focus that role promises (decision 9); items that overflow scroll along its axis in a
thin ScrollArea whose bar shows on hover, the toolbar itself being the viewport.
Root> <import Toolbar
Toolbar.const Text: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Text
A run of text that takes the free space and truncates; not an item, so roving focus skips it.
Text>Contacts</import Toolbar
Toolbar.const Text: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Text
A run of text that takes the free space and truncates; not an item, so roving focus skips it.
Text> <import Toolbar
Toolbar.const Separator: React.ForwardRefExoticComponent<Omit<Toolbar.SeparatorProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Separator
A rule across the toolbar's axis (vertical in a horizontal toolbar), or with variant='gap' a growing spacer; not an
item, so roving focus skips it.
Separator variant?: "gap" | "line" | undefined
gap is an empty spacer that grows, pushing the items after it to the toolbar's end.
variant='gap' /> <import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>export Root
Root icon?: string | undefined
Leading icon.
icon='ph--plus--regular' label?: string | undefined
Visible text; children take precedence.
Required: names the button (aria-label) and shows in a Tooltip.
label='Add contact' iconOnly?: boolean | undefined
A control-sized square inset in a block-sized cell (follow-up 19), showing only the icon.
iconOnly /> </import Toolbar
Toolbar.const Root: React.ForwardRefExoticComponent<Omit<Toolbar.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
role=toolbar with the roving focus that role promises (decision 9); items that overflow scroll along its axis in a
thin ScrollArea whose bar shows on hover, the toolbar itself being the viewport.
Root> </import Panel
Panel.const Header: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Header
The top row on the bar aspect, which steps off whatever level hosts the panel; it sizes to its content, so it takes
no space when empty and one block when it holds a Toolbar.Root.
Header> <import Panel
Panel.const Body: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Body
The growing middle row, a plain slot: it neither scrolls nor adds a gutter, so content composes its own frame
(asChild onto a ScrollArea.Root around a Container, or a canvas that fills the row). The first Container under it
takes the panel's gutter unless it names one. Like the header and footer it is no query container, so its content
collapses against the panel.
Body asChild?: boolean | undefined
asChild> <import ScrollArea
ScrollArea.const Root: React.ForwardRefExoticComponent<Omit<ScrollArea.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
Non-scrolling frame: hosts the overlay thumbs and is the query container for its content.
Root> <import ScrollArea
ScrollArea.const Viewport: React.ForwardRefExoticComponent<Omit<ScrollArea.ViewportProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Viewport
The scrolling element; under asChild it is the child (e.g. a Container) itself.
Viewport asChild?: boolean | undefined
asChild> <import Layout
Layout.const Container: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
Grid part (decision 5): every prop is a data-* attribute resolved by theme/container.css.
Container gutter?: Layout.Gutter | undefined
inherit makes the container a subgrid of its parent's tracks; any other value starts a fresh template. Unset, it
is the enclosing Panel.Body's gutter for the first Container under the Body, and inherit everywhere else.
gutter='rail'> {const CONTACTS: string[]
CONTACTS.Array<string>.map<React.JSX.Element>(callbackfn: (value: string, index: number, array: string[]) => React.JSX.Element, thisArg?: any): React.JSX.Element[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((name: string
name) => ( <import Layout
Layout.const Container: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
Grid part (decision 5): every prop is a data-* attribute resolved by theme/container.css.
Container React.Attributes.key?: React.Key | null | undefined
key={name: string
name} layout?: "row" | "stack" | undefined
stack places each child across the content track; row flows children through its inner tracks.
layout='row'> <import Layout
Layout.const Block: React.ForwardRefExoticComponent<Omit<Layout.BlockProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
A block-sized square that centres its content (typically an Icon); compact drops the fixed height.
Block rail?: "start" | "end" | undefined
Places the block in a parent Container's start or end gutter.
rail='start'> <import Icon
Icon.const Icon: React.ForwardRefExoticComponent<Omit<Omit<React.SVGProps<SVGSVGElement>, "ref">, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & { icon: string; label?: string; hue?: Icon.IconHue; valence?: Icon.IconValence; tone?: Icon.IconTone; spin?: boolean; size?: Size;} & React.RefAttributes<SVGSVGElement>>
Icon icon: string
icon='ph--user--regular' /> </import Layout
Layout.const Block: React.ForwardRefExoticComponent<Omit<Layout.BlockProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
A block-sized square that centres its content (typically an Icon); compact drops the fixed height.
Block> <import Typography
Typography.const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLParagraphElement>>export Text
Text whose first line is centred in a block, so it lines up with a Block or control beside it however many lines
it wraps to. Renders a <p>; asChild puts the metrics on a heading or other text element instead.
Text>{name: string
name}</import Typography
Typography.const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLParagraphElement>>export Text
Text whose first line is centred in a block, so it lines up with a Block or control beside it however many lines
it wraps to. Renders a <p>; asChild puts the metrics on a heading or other text element instead.
Text> </import Layout
Layout.const Container: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
Grid part (decision 5): every prop is a data-* attribute resolved by theme/container.css.
Container> ))} </import Layout
Layout.const Container: React.ForwardRefExoticComponent<Omit<Layout.ContainerProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
Grid part (decision 5): every prop is a data-* attribute resolved by theme/container.css.
Container> </import ScrollArea
ScrollArea.const Viewport: React.ForwardRefExoticComponent<Omit<ScrollArea.ViewportProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Viewport
The scrolling element; under asChild it is the child (e.g. a Container) itself.
Viewport> </import ScrollArea
ScrollArea.const Root: React.ForwardRefExoticComponent<Omit<ScrollArea.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
Non-scrolling frame: hosts the overlay thumbs and is the query container for its content.
Root> </import Panel
Panel.const Body: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Body
The growing middle row, a plain slot: it neither scrolls nor adds a gutter, so content composes its own frame
(asChild onto a ScrollArea.Root around a Container, or a canvas that fills the row). The first Container under it
takes the panel's gutter unless it names one. Like the header and footer it is no query container, so its content
collapses against the panel.
Body> <import Panel
Panel.const Footer: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Footer
The bottom row on the bar aspect; like Header it sizes to its content, holding a Toolbar.Root when it needs one.
Footer> <import Toolbar
Toolbar.const Root: React.ForwardRefExoticComponent<Omit<Toolbar.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
role=toolbar with the roving focus that role promises (decision 9); items that overflow scroll along its axis in a
thin ScrollArea whose bar shows on hover, the toolbar itself being the viewport.
Root> <import Toolbar
Toolbar.const Text: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Text
A run of text that takes the free space and truncates; not an item, so roving focus skips it.
Text>{const CONTACTS: string[]
CONTACTS.Array<string>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
length} contacts</import Toolbar
Toolbar.const Text: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Text
A run of text that takes the free space and truncates; not an item, so roving focus skips it.
Text> </import Toolbar
Toolbar.const Root: React.ForwardRefExoticComponent<Omit<Toolbar.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
role=toolbar with the roving focus that role promises (decision 9); items that overflow scroll along its axis in a
thin ScrollArea whose bar shows on hover, the toolbar itself being the viewport.
Root> </import Panel
Panel.const Footer: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Footer
The bottom row on the bar aspect; like Header it sizes to its content, holding a Toolbar.Root when it needs one.
Footer> </import Panel
Panel.const Root: React.ForwardRefExoticComponent<Omit<Panel.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
The plank host: fills its parent, sets data-size and a level for its subtree, and is the pane's
query container, so its header, body and footer collapse at the same pane width.
Root>);
| Part | What it is |
|---|---|
Panel.Root |
The shell. It fills its parent and sets the size and surface for everything in it |
Panel.Header |
A row sized to its content, usually a toolbar |
Panel.Body |
The area that takes the remaining height. Use asChild to put it on a ScrollArea.Root |
Panel.Footer |
A row sized to its content, such as a status line |
Panel.Root
Section titled “Panel.Root”Panel.Root takes these props:
| Prop | Type | Effect |
|---|---|---|
size |
Size |
Sets the size of everything in the panel |
level |
'sunken' | 'chrome' | 'base' | 'raised' | 'overlay' | 'popup' |
Sets the surface. 'base' by default |
width |
'document' |
Keeps the body’s content at reading width, centered, while it still scrolls at the panel’s edge |
gutter |
'rail' | 'inset' | 'sm' | 'md' | 'lg' | 'none' |
Sets the gutter of the first container in the body. 'sm' by default |
The panel is a container query, so its header, body and footer can change layout together at a narrow width.