Components
Every component below has a short description, the code to produce it, and its props. Zuper draws each component with its own design — these examples show the shape of the code, not the exact pixels.
Button
Actions. The only component that takes onPress.
<Button label="Create warranty" onPress={() => ui.toast('Pressed')} />| Prop | Type | Default | Notes |
|---|---|---|---|
label | string | — | The button text |
variant | `'primary' | 'secondary'` | 'secondary' |
disabled | boolean | false | |
onPress | () => void | — | Runs in your worker |
Text
Text, in three variants.
<Text>Warranty expires on 12 Mar 2027</Text>| Prop | Type | Default | Notes |
|---|---|---|---|
variant | `'body' | 'heading' | 'muted'` |
children | string | — |
Badge
A status.
<Badge label="Active" tone="success" />| Prop | Type | Default | Notes |
|---|---|---|---|
label | string | — | |
tone | `'neutral' | 'success' | 'warning' |
Stack
Layout. Use it instead of div.
<Stack>
<Text variant="heading">Warranty</Text>
<Badge label="Active" tone="success" />
<Text variant="muted">Expires 12 Mar 2027</Text>
</Stack>| Prop | Type | Default | Notes |
|---|---|---|---|
direction | `'row' | 'column'` | 'column' |
gap | `'small' | 'medium' | 'large'` |
children | components | — |
DescriptionList
Label and value pairs. Values are strings.
<DescriptionList
items={[
{ label: 'Customer', value: 'Ava Martin' },
{ label: 'Status', value: 'In progress' },
{ label: 'Plan', value: 'Gold, 3 years' },
]}
/>| Prop | Type | Default | Notes |
|---|---|---|---|
items | { label: string; value: string }[] | — | Format numbers and dates first |
Table
Read-only data. Cells are strings or numbers, so format dates and amounts first.
<Table
columns={[
{ key: 'part', label: 'Part' },
{ key: 'qty', label: 'Qty' },
{ key: 'amount', label: 'Amount', align: 'end' },
]}
rows={[
{ part: 'Air filter 20x25', qty: 2, amount: '$24.00' },
{ part: 'Thermostat', qty: 1, amount: '$129.00' },
]}
emptyText="No parts used yet"
/>| Prop | Type | Default | Notes |
|---|---|---|---|
columns | `{ key; label; align?: 'start' | 'end' }[]` | — |
rows | `Record<string, string | number>[]` | — |
emptyText | string | — | Shown when rows is empty |
Card
Groups content in a tab.
<Card title="Warranty">
<DescriptionList items={[{ label: 'Plan', value: 'Gold, 3 years' }, { label: 'Expires', value: '12 Mar 2027' }]} />
</Card>| Prop | Type | Default | Notes |
|---|---|---|---|
title | string | — | |
children | components | — |
Image
An image from an https address on any host. A bad address or a failed load shows a placeholder.
<Image src="https://files.acme.com/units/condenser.jpg" alt="Condenser unit" />| Prop | Type | Default | Notes |
|---|---|---|---|
src | string | — | https on any host; allowedDomains is not needed |
alt | string | — | Text for screen readers, up to 300 characters |
size | `'small' | 'medium' | 'large'` |
New in
@zuperpro/app-sdk2.0.0-beta. On an older SDK, runnpm install --save-dev @zuperpro/app-sdk@beta.
- Any https host. Unlike Frame,
Imagedoesn't need the host inallowedDomains, so you can show Zuper's own files, such as job photos and attachments, whose addresses only arrive at run time. - Works in cards, tabs and dialogs, not only in dialogs like
Frame. - https only. While your app runs from
zp app dev,http://localhostimages are allowed too. - Placeholder. A non-https or invalid address, or an image that fails to load, shows a crossed-out photo icon. Hover it to see why.
TextField
Input for text, a number, a date or a file. Controlled: keep value in state and set it in onChange.
const [note, setNote] = useState('');
<TextField label="Note" placeholder="Add a note for the technician" value={note} onChange={setNote} />| Prop | Type | Default | Notes |
|---|---|---|---|
type | `'text' | 'number' | 'date' |
label | string | — | |
value | string (number: `string | number`) | — |
placeholder | string | — | text and number |
multiline | boolean | false | text only |
min, max | string (number: `string | number`) | — |
step | `string | number` | — |
accept | string | — | attachment only, e.g. 'image/*,application/pdf' |
required | boolean | false | |
error | string | — | Shown under the field |
onChange | see below | — |
New in
@zuperpro/app-sdk2.0.0-beta. On an older SDK, runnpm install --save-dev @zuperpro/app-sdk@beta.
What onChange gets
| type | onChange gets |
|---|---|
text | string |
number | number, or null when the field is emptied or holds no valid number |
date | A 'YYYY-MM-DD' string, '' when cleared |
attachment | { name, size, mimeType, base64 } (AttachmentFile), or null when removed |
- Attachments are one file of at most 5 MB. Zuper reads the file;
base64has nodata:prefix. Uploading it is your app's job, usually through a server function. - Zuper keeps the picked file, not your state. To clear an attachment field after a submit, remount it with a new
key.
Select
A choice of one option, or several with multiple. Controlled, like TextField.
const [plan, setPlan] = useState('gold');
<Select label="Plan" required
options={[
{ label: 'Silver, 1 year', value: 'silver' },
{ label: 'Gold, 3 years', value: 'gold' },
{ label: 'Platinum, 5 years', value: 'platinum' },
]}
value={plan}
onChange={setPlan}
/>| Prop | Type | Default | Notes |
|---|---|---|---|
options | { label: string; value: string }[] | — | |
multiple | boolean | false | Pick several options |
value | string | — | Single mode |
values | string[] | — | With multiple; a separate prop from value |
onChange | (value: string) => void, or (values: string[]) => void with multiple | — | |
label, placeholder, required, error | The same as TextField |
New in
@zuperpro/app-sdk2.0.0-beta. On an older SDK, runnpm install --save-dev @zuperpro/app-sdk@beta.
With multiple, the menu stays open while the user ticks options, and onChange gets every ticked value in the order of options, not the order they were ticked.
Dialog
DialogBody and DialogActions hold a dialog extension's content and footer buttons. Zuper draws the frame, the title and the close button.
export function openNoteDialog() {
return ui.openDialog<{ note: string }>('note-dialog');
}
export default defineExtension({
type: 'dialog',
id: 'note-dialog',
title: 'Add a note',
objects: ['job'],
render: ({ close }) => <NoteForm close={close} />,
});
function NoteForm({ close }: { close: (result?: { note: string }) => void }) {
const [note, setNote] = useState('');
return (
<>
<DialogBody>
<TextField label="Note" multiline value={note} onChange={setNote} />
</DialogBody>
<DialogActions>
<Button label="Cancel" onPress={() => close()} />
<Button label="Save" variant="primary" onPress={() => close({ note })} />
</DialogActions>
</>
);
}| Prop | Type | Default | Notes |
|---|---|---|---|
size (extension) | `'sm' | 'md' | 'lg' |
render | ({ record, input, close }) => UI | — | |
close(result?) | ui.openDialog resolves with result, or undefined when dismissed |
ui.openDialog resolves with what the dialog passes to close(result), or with undefined when the user dismisses it. One dialog per app can be open at a time.
Frame
Shows a web page, such as your own product's screen. Dialogs only.
// zuper.app.json → "allowedDomains": ["pages.acme.com"]
export default defineExtension({
type: 'dialog',
id: 'picker',
title: 'Picker',
objects: ['job'],
render: () => (
<DialogBody>
<Frame src="https://pages.acme.com/picker" label="Picker" />
</DialogBody>
),
});| Prop | Type | Default | Notes |
|---|---|---|---|
src | string | — | https, on a host in allowedDomains |
label | string | — | Accessible name |
height | `'small' | 'medium' | 'large' |
onMessage | (m: FrameMessage) => void | — | Messages from the page (ZuperEmbed) |
ref | FrameHandle | — | ref.current.send(type, content) |
- Dialogs only.
zp app validateand Zuper both refuse aFramein a card, tab or action. Use afullscreendialog withheight="fill"to give the page the whole window. - https only, on your allowed domains. Zuper checks every address again when it draws the frame, including addresses you build in code. While your app runs from
zp app dev,http://localhostandhttp://127.0.0.1pages are allowed too, if you list them. - The site must allow framing. Many sites send
X-Frame-Optionsor aframe-ancestorspolicy, and the browser then refuses to show them. Test the page you need. - Sandboxed. The page can't navigate the Zuper tab, gets no referrer, and can't read anything of Zuper's.
To exchange messages with the page, see ZuperEmbed.
Updated about 1 hour ago
