Dialogs and messages
These components open a window, show a message in the page or show an empty list. The question before deleting and the toasts are not components: they are functions, described in Functions.
Dialog
Hodi's window, centred on the screen, with a tinted header and a cross to close it. The Escape key, a click beside the window or the cross call onClose. The window's buttons go in DialogActions.
import { Button, Dialog, DialogActions, TextField } from 'hodi:sdk'
import { Hand } from 'lucide-react'
<Dialog
open={open}
onClose={close}
size="compact"
title="New greeting"
intro="It replaces “Hi”."
>
<TextField
icon={Hand}
aria-label="Greeting"
placeholder="Hey"
/>
<DialogActions>
<Button onClick={close}>Cancel</Button>
<Button look="primary" onClick={save}>Save</Button>
</DialogActions>
</Dialog>openbooleantrue when the window is open.
onClose() => voidCalled when the person closes the window: with Escape, the cross or a click beside it.
title?ReactNodeThe window's title. Without a title, labelledBy must name the window.
intro?ReactNodeOne or two sentences under the title, which say what the window is for.
size?'compact' | 'wide'The window's width: compact for a question or a short form, wide when there is more to read.
onBack?() => voidAdds a back arrow before the title, which calls this function.
labelledBy?stringThe id of the element that names the window, for screen readers.
describedBy?stringThe id of the element that describes the window, for screen readers.
childrenReactNodeThe window's content, then its DialogActions.
DialogActions
The row of buttons at the bottom of a window, under a line. The secondary button, such as Cancel, goes on the left; the action's button goes on the right.
childrenReactNodeThe row's buttons. The main button comes last.
className?stringOne more CSS class, prefixed by the plugin's id.
StatusLine
A message line under a field: in blue to say what is happening, in red to say something failed.
Saved 2 min ago.
import { StatusLine } from 'hodi:sdk'
<StatusLine tone="info">Saved 2 min ago.</StatusLine>tone'info' | 'error'The line's colour: info in blue, error in red.
childrenstringThe message, already translated.
Notice
A box with an icon and a title, for information that must stay visible in the page, such as a warning.
import { Notice } from 'hodi:sdk'
import { ExternalLink, Info } from 'lucide-react'
<Notice
title="New version"
icon={Info}
action={{
label: 'See',
icon: ExternalLink,
href: links.plugins
}}
>
Hello world 0.2 says hello in Dutch.
</Notice>titlestringThe box's title.
iconLucideIconThe box's icon, a Lucide icon.
childrenReactNodeThe text under the title.
tone?'info' | 'warning' | 'error'The box's colour: info in blue by default, warning in yellow, error in red.
action?NoticeActionA button at the end of the box. It has a label, an icon, and an onClick or an href.
side?ReactNodeRound buttons at the end of the box, in place of action.
href?stringMakes the whole box a link to this address, opened in a new tab.
EmptyState
What an empty list shows, or a list that couldn't load: an icon, a title and one line of text at most.
No hellos
The household’s greetings arrive here.
import { EmptyState } from 'hodi:sdk'
import { Inbox } from 'lucide-react'
<EmptyState
icon={<Inbox size={28} />}
title="No hellos"
compact
>
The household’s greetings arrive here.
</EmptyState>iconReactNodeThe icon, shown at 28 px in a square.
titlestringThe title, which says what is missing, such as No hellos.
children?ReactNodeOne line of text under the title, no more.
actions?ReactNodeButtons under the text, such as Try again.
tone?'default' | 'danger'danger turns the icon red, when the list couldn't load.
compact?booleanA smaller version, for an empty state placed above other content.