Skip to content
silverpoint
Documentation menu

UI components · Overlays · new in 0.7

SpToast · SpToaster

Notices that stack in a corner and dismiss themselves; error and warning are announced assertively. Group: Overlays · new in silverpoint 0.7, in React, Vue, Angular and Reflex (sp_toast · sp_toaster).

Live

Drawn here with the Reflex version, sp_toast · sp_toaster, on the ground you pick:

Ground
Substrate
Mode
Palette
  1. SavedThe drawing was saved.

Code

The same example in each framework; pick one once and every example on the site follows it.

tsx
import { useState } from 'react';
import { SpButton } from '@silverpoint/react/ui/button';
import { SpToast, SpToaster } from '@silverpoint/react/ui/toast';

export function Save() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <SpButton onClick={() => setOpen(true)}>Save</SpButton>
      <SpToaster position="bottom-end">
        {/* error and warning are announced assertively; onOpenChange(false) when it closes */}
        <SpToast title="Saved" description="The drawing was saved." kind="success" open={open} onOpenChange={setOpen} />
      </SpToaster>
    </>
  );
}

Import

Import @silverpoint/grounds/ui.css once, beside styles.css; Reflex adds it for you. Every adapter also exports it from the ui barrel.

FrameworkImport
Reactimport { SpToast, SpToaster } from '@silverpoint/react/ui/toast';
Vueimport { SpToast, SpToaster } from '@silverpoint/vue/ui/toast';
Angularimport { SpToast, SpToaster } from '@silverpoint/angular/ui/toast'; · sp-toast · sp-toaster
Reflexfrom reflex_silverpoint_react import sp_toast, sp_toaster

Events, values and slots

Each framework's own way. A change carries the new value itself (a key, a page, a number, a bool), never a DOM event.

ReactVueAngularReflex
Open stateopen + onOpenChange, or defaultOpenv-model:open, or default-open[(open)], or [defaultOpen]open + on_open_change, or default_open
Actionaction#action slot<ng-template spAction>—
Toaster<SpToaster> around the toasts<SpToaster><sp-toaster>sp_toaster(*toasts)

Props

SpToast

React / AngularVueTypeDescription
title requiredtitlestringThe toast's first line.
description descriptionstringA line under the title.
kind kindAlertKindDefault 'info'.
duration durationnumberms, at least 1000, or Infinity; the toaster's when omitted.
closeLabel close-labelstringDefault 'Dismiss'.

SpToaster

React / AngularVueTypeDescription
position position'bottom-end' | 'bottom-start' | 'top-end' | 'top-start'Default 'bottom-end'.
duration durationnumberDefault 5000 ms.
label labelstringDefault 'Notifications'.

In Reflex the names are snake_case; the Reflex column of Composed components shows the builder's arguments.

Common props

Every UI component also takes these, falling back to the dashboard it sits in, then to the provider. In Reflex they read silverpoint_provider too; only sp_trigger does not: pass them to it.

React / AngularVueReflexTypeDescription
idididstrThe frame variant and every related id derive from it.
groundgroundgroundLiteral['silverpoint', 'cyanotype'] | str | dict[str, Any]Style ground: "silverpoint" or "cyanotype", or a ground object. Defaults to the dashboard's, then the provider's, or silverpoint.
substratesubstratesubstrateLiteral['cream', 'green', 'blue', 'ochre', 'prussian']Prepared substrate within the ground.
modemodemodeLiteral['ink', 'precision']ink by default; precision disables inking.
seedseedseedstr | intSeed of the frame's hand; overrides id for the frame variant only.
sizesizesizeLiteral['sm', 'md', 'lg']Control size: sm, md (default) or lg.
palettepalettepalettedict[str, str]Colours over the ground's (set with palette=), merged over the dashboard's and the provider's.
classNameclass-nameclass_namestrAdded to the component's root element, after its own classes.
palettepalettepalettePaletteColours over the ground's, merged over the dashboard's and the provider's.
Report it
Found something wrong with SpToast? Open an issue on GitHub — the form comes pre-filled with the component and the version.