Every type is exported from the root: import type { … } from '@cloudlet/toast'. Grouped as in the contracts, each with the page that uses it. Core types take a Slot parameter for rich content; the React… aliases at the end fix it to ReactNode.
Identity
Handles and tokens are capabilities minted by the controller. They are never built by hand, compared across controllers or stored across reloads.
Type
Definition
Description
NotificationHandle
{ id, controller, generation }
One appearance of a notification, returned by show and track. Pass it to update and dismiss. Not a serializable ID: keep the id string for that.
Description<Slot>, the text under the title; show and update:
Variant
Fields
Description
{ kind: 'text' }
text: string
Plain text; may be empty.
{ kind: 'rich' }
content: Slot, announcement: string
Your own non-interactive content (a ReactNode), and the non-empty text screen readers hear instead of it. Buttons and links belong in the action.
Progress
Progress, a ring around the icon; show and update:
Variant
Fields
Description
{ kind: 'indeterminate' }
label?: string
Work of unknown length.
{ kind: 'determinate' }
value: number, label?: string
value is finite, from 0 to 1; out-of-range values are rejected, not clamped. label names the progress for assistive technology.
PrimaryAction
PrimaryAction is a CommandAction, a NavigationAction or a FormAction; a notification has at most one. Operations & cancellation shows commands and links, Forms the form.
CommandAction runs your function:
Prop
Type
Default
Description
kind
'command'
—
Required.
label
string
—
Required, non-empty. The button text.
run
(context: ActionContext) => unknown
—
Required. May return a value, nothing or a promise. While it runs the button is pending and a second press is refused; success closes the notification (action-success), failure keeps it with a message and allows another try.
errorMessage
(error: unknown) => string
messages.actionError
Turns a failure into the message shown on the card.
agent
'allow' | 'confirm' | 'deny'
'confirm'
What an agent may do with this command through @cloudlet/toast/agent: press it, press it once a person approves, or never.
ActionContext, passed to run:
Field
Type
Description
handle
NotificationHandle
The notification.
token
ActionAttemptToken
This run.
NavigationAction is a real link:
Prop
Type
Default
Description
kind
'link'
—
Required.
label
string
—
Required, non-empty. The link text.
href
string
—
Required. Relative and fragment URLs, http:, https:, mailto: and tel:; other schemes are rejected.
target
'_self' | '_blank' | '_parent' | '_top'
—
Where it opens. _blank always gets noopener.
rel
string
—
Your rel; noopener is added to it, never replacing it.
Following the link closes the notification with the reason navigation; modifier keys and new tabs behave as for any link.
FormAction puts one to three fields in the Island and submits them like a command:
Prop
Type
Default
Description
kind
'form'
—
Required.
fields
readonly FormField[]
—
Required, one to three, with unique names.
label
string
—
Required, non-empty. The submit button's accessible name.
run
(context: FormContext) => unknown
—
Required. Called with the values once they pass the checks; pending, success and failure work as for a command.
errorMessage
(error: unknown) => string
messages.actionError
Turns a failure into the message under the form.
validate
(values: FormValues) => FormValidation
—
Runs on submit after required and maxLength.
agent
'allow' | 'confirm' | 'deny'
'confirm'
What an agent may do with this form through @cloudlet/toast/agent: submit it, submit it once a person approves, or never. None of them stops an agent from filling the fields; a person can always submit.
FormField describes one field:
Prop
Type
Default
Description
name
string
—
Required. The key of its value in FormValues.
kind
FormFieldKind
—
Required: 'text' for one line, 'textarea' for several.
label
string
—
Required. Read by screen readers; also the placeholder when there is none.
placeholder
string
label
The hint inside the empty field.
defaultValue
string
''
The starting value; not longer than maxLength.
required
boolean
false
An empty value, or only spaces, stops the submit with messages.fieldRequired.
maxLength
number
—
A positive integer; a longer value stops the submit with messages.fieldTooLong.
autoComplete
string
—
The field's autocomplete.
inputMode
FormInputMode
—
The on-screen keyboard: 'text', 'email', 'numeric', 'decimal', 'tel', 'url' or 'search'.
Type
Definition
Description
FormValues
Readonly<Record<Name, string>>
Each field name to its text, as typed. TypeScript takes the names from fields, so values.reply is a string and a misspelt name does not compile.
FormContext
ActionContext and values: FormValues
Passed to the form's run.
FormValidation
true | string | Partial<Record<Name, string>>
What validate returns: true to submit, a string for a message under the form, or messages keyed by field name.
CloseReason
CloseNotice is what onClose receives: handle, reason (a CloseReason) and source, a ChangeSource that says who closed it:
CancellationSignal is the minimal abort port the core needs, so it runs without the DOM. A native AbortSignal implements it, and the React controller gives factories a real AbortSignal (track).
Member
Type
Description
aborted
boolean
Cancellation was requested.
reason
unknown
The reason passed to cancel.
throwIfAborted
() => void
Throws the reason if aborted.
addEventListener
(type: 'abort', listener, options?) => void
Listens for the request; { once: true } is supported.
ControllerSnapshot.island; reason, current and source are null exactly when closed. source is the ChangeSource that opened the Island or moved it to its current notification last.
IslandReason
'user' | 'attention'
IslandSnapshot.reason: whether the user opened the Island or a notification needing attention did.