PanelNodes
The components from which a panel or an outline type is built. Each one is a function that returns a node, which is a plain description of the component that the app draws. A property whose value is undefined is left out. Because every component is a typed function, a misspelled property is a type error.
Example
Section titled “Example”ctx.ui.panel({ id: 'today', title: 'Today', render: () => ctx.ui.stack({ axis: 'vertical', gap: 8 }, [ ctx.ui.text({ text: 'Good morning', style: 'title' }), ctx.ui.button({ title: 'Start', action: () => ctx.dispatch(start.intent({})) }), ]),});Extended by
Section titled “Extended by”Methods
Section titled “Methods”board()
Section titled “board()”board(props, children): PanelNode;Displays a board: a row of columns that hold cards, which the person can drag from one column to another.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ add?: PanelHandler<{ }>; addTitle?: string; } |
add is invoked when the person presses the button that creates a column, and addTitle is the text of that button. |
props.add? |
PanelHandler<{ }> |
- |
props.addTitle? |
string |
- |
children |
Children |
the columns of the board, made with column |
Returns
Section titled “Returns”the node
button()
Section titled “button()”button(props): PanelNode;Displays a button. Pressing it invokes action, or runs the request given as intent. The optional role, which is either destructive or cancel, adjusts the appearance of the button.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
Pressable & object |
title is the text of the button, role adjusts its appearance, and action or intent is what happens when it is pressed. |
Returns
Section titled “Returns”the node
card()
Section titled “card()”card(props): PanelNode;Displays one card of a column. Most properties are handlers: tap is invoked with { card } when the card is pressed, open with { card } when its title is double-clicked, edit with { card, title } when the person has typed a new title, and drag with { card, column, before } when the card is dragged and dropped on a column or on another card. While editing is true, the title is displayed as an editable field.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ done?: boolean; drag?: PanelHandler<{ before?: string; card: string; column?: string; }>; edit?: PanelHandler<{ card: string; title: string; }>; editing?: boolean; id: string; open?: PanelHandler<{ card: string; }>; subtitle?: string; tap?: PanelHandler<{ card: string; }>; title: string; } |
id identifies the card, title is its text, subtitle is an optional second line, done marks the card as completed, and tap, open, edit, drag and editing are described above. |
props.done? |
boolean |
- |
props.drag? |
PanelHandler<{ before?: string; card: string; column?: string; }> |
- |
props.edit? |
PanelHandler<{ card: string; title: string; }> |
- |
props.editing? |
boolean |
- |
props.id |
string |
- |
props.open? |
PanelHandler<{ card: string; }> |
- |
props.subtitle? |
string |
- |
props.tap? |
PanelHandler<{ card: string; }> |
- |
props.title |
string |
- |
Returns
Section titled “Returns”the node
chart()
Section titled “chart()”chart(props): PanelNode;Displays a chart, drawn as bars or as lines depending on kind. Each entry of series supplies a list of numbers and, optionally, a label.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ kind?: "bar" | "line"; label?: string; series: readonly object[]; } |
kind is bar or line, label is an optional title, and series is the list of data series. |
props.kind? |
"bar" | "line" |
- |
props.label? |
string |
- |
props.series |
readonly object[] |
- |
Returns
Section titled “Returns”the node
column()
Section titled “column()”column(props, children): PanelNode;Displays one column of a board, with a header that shows its title and, optionally, the number of cards. Most properties are handlers: drop is invoked with { card, column } when a card is dropped on the column, add with { column } when the person presses the + button, open with { column } when the title is double-clicked, and edit with { column, title } when the person has typed a new title. While editing is true, the title is displayed as an editable field.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ add?: PanelHandler<{ column: string; }>; count?: number; drop?: PanelHandler<{ card: string; column: string; }>; edit?: PanelHandler<{ column: string; title: string; }>; editing?: boolean; id: string; open?: PanelHandler<{ column: string; }>; title: string; } |
id identifies the column, title and count appear in its header, and drop, add, open, edit and editing are described above. |
props.add? |
PanelHandler<{ column: string; }> |
- |
props.count? |
number |
- |
props.drop? |
PanelHandler<{ card: string; column: string; }> |
- |
props.edit? |
PanelHandler<{ column: string; title: string; }> |
- |
props.editing? |
boolean |
- |
props.id |
string |
- |
props.open? |
PanelHandler<{ column: string; }> |
- |
props.title |
string |
- |
children |
Children |
the cards of the column, made with card |
Returns
Section titled “Returns”the node
divider()
Section titled “divider()”divider(props?): PanelNode;Draws a thin line between the components that surround it.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props? |
Record<never, never> |
an empty object, because a divider has no properties. |
Returns
Section titled “Returns”the node
field()
Section titled “field()”field(props): PanelNode;Displays an editable field with a label. The optional kind restricts the content to text or to numbers, and action is invoked with { value } each time the content changes.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ action?: PanelHandler<{ value: string | number; }>; kind?: "number" | "text"; label: string; value?: string | number; } |
label is the text of the field, value is its current content, kind is text or number, and action receives { value } when the content changes. |
props.action? |
PanelHandler<{ value: string | number; }> |
- |
props.kind? |
"number" | "text" |
- |
props.label |
string |
- |
props.value? |
string | number |
- |
Returns
Section titled “Returns”the node
icon()
Section titled “icon()”icon(props): PanelNode;Displays an icon chosen by name.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ name: string; } |
name is the name of the icon. |
props.name |
string |
- |
Returns
Section titled “Returns”the node
list()
Section titled “list()”list(props, children): PanelNode;Displays its children one below the other. The children are normally row components.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
Record<never, never> |
an empty object, because a list has no properties. |
children |
Children |
the components of the list |
Returns
Section titled “Returns”the node
picker()
Section titled “picker()”picker(props): PanelNode;Lets the person choose one option from a list. The app invokes action with { value } when the selection changes.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ action?: PanelHandler<{ value: string; }>; label: string; options: readonly (readonly [string, string])[]; value: string; } |
label is the text of the control, value is the current selection, options is an array of [value, label] pairs, and action receives { value } when the selection changes. |
props.action? |
PanelHandler<{ value: string; }> |
- |
props.label |
string |
- |
props.options |
readonly (readonly [string, string])[] |
- |
props.value |
string |
- |
Returns
Section titled “Returns”the node
progress()
Section titled “progress()”progress(props): PanelNode;Displays a progress bar. The value is the completed percentage, between 0 and 100. The optional label is the text that assistive technologies announce.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ label?: string; value: number; } |
value is the completed percentage, and label is the text for assistive technologies. |
props.label? |
string |
- |
props.value |
number |
- |
Returns
Section titled “Returns”the node
row(props): PanelNode;Displays one entry of a list: a title, with an optional subtitle, and an optional accessory text at the end of the line. A row can be pressed, in which case the app invokes action or runs the request given as intent.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
Pressable & object |
title is the main text, subtitle is a second line, accessory is a short text at the end of the line, and action or intent is what happens when the row is pressed. |
Returns
Section titled “Returns”the node
spacer()
Section titled “spacer()”spacer(props?): PanelNode;Leaves an empty space between components.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props? |
Record<never, never> |
an empty object, because a spacer has no properties. |
Returns
Section titled “Returns”the node
stack()
Section titled “stack()”stack(props, children): PanelNode;Arranges its children in a row or in a column, depending on axis, with a fixed space between them.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ axis?: "horizontal" | "vertical"; gap?: number; } |
axis selects the direction, horizontal or vertical, and gap sets the space between two children, in pixels. |
props.axis? |
"horizontal" | "vertical" |
- |
props.gap? |
number |
- |
children |
Children |
the components to arrange |
Returns
Section titled “Returns”the node
text()
Section titled “text()”text(props): PanelNode;Displays a piece of text. The optional style selects its appearance: title renders a larger and bolder text, and caption renders a smaller and muted one. Without a style, the text has the ordinary appearance.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ style?: string; text: string; } |
text is the text to display, and style is its appearance. |
props.style? |
string |
- |
props.text |
string |
- |
Returns
Section titled “Returns”the node
toggle()
Section titled “toggle()”toggle(props): PanelNode;Displays a switch with a label. The app invokes action with { value } each time the person flips the switch.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
{ action?: PanelHandler<{ value: boolean; }>; label: string; value?: boolean; } |
label is the text next to the switch, value is its current state, and action receives { value } when the person changes it. |
props.action? |
PanelHandler<{ value: boolean; }> |
- |
props.label |
string |
- |
props.value? |
boolean |
- |
Returns
Section titled “Returns”the node
