UI components · Overlays · new in 0.7
SpToast · SpToaster
Live
Drawn here with the Reflex version, sp_toast · sp_toaster, on the ground you pick:
Code
The same example in each framework; pick one once and every example on the site follows it.
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>
</>
);
}<script setup lang="ts">
import { ref } from 'vue';
import { SpButton } from '@silverpoint/vue/ui/button';
import { SpToast, SpToaster } from '@silverpoint/vue/ui/toast';
const open = ref(false);
</script>
<template>
<SpButton @click="open = true">Save</SpButton>
<SpToaster position="bottom-end">
<SpToast v-model:open="open" title="Saved" description="The drawing was saved." kind="success" />
</SpToaster>
</template>import { Component, signal } from '@angular/core';
import { SpButton } from '@silverpoint/angular/ui/button';
import { SpToast, SpToaster } from '@silverpoint/angular/ui/toast';
@Component({
selector: 'app-save',
imports: [SpButton, SpToast, SpToaster],
template: `
<button spButton (click)="open.set(true)">Save</button>
<sp-toaster position="bottom-end">
<sp-toast [(open)]="open" title="Saved" description="The drawing was saved." kind="success" />
</sp-toaster>
`,
})
export class Save {
protected readonly open = signal(false);
}sp_button("Save", on_click=State.save) # sets toast_open = True
sp_toaster(
sp_toast(
"Saved",
"The drawing was saved.",
kind="success",
open=State.toast_open,
on_open_change=State.set_toast_open, # False when it closes
),
position="bottom-end", # the default; logical, so it mirrors in right-to-left text
)Import
Import @silverpoint/grounds/ui.css once, beside styles.css; Reflex adds it for you. Every adapter also exports it from the ui barrel.
| Framework | Import |
|---|---|
| React | import { SpToast, SpToaster } from '@silverpoint/react/ui/toast'; |
| Vue | import { SpToast, SpToaster } from '@silverpoint/vue/ui/toast'; |
| Angular | import { SpToast, SpToaster } from '@silverpoint/angular/ui/toast'; · sp-toast · sp-toaster |
| Reflex | from 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.
| React | Vue | Angular | Reflex | |
|---|---|---|---|---|
| Open state | open + onOpenChange, or defaultOpen | v-model:open, or default-open | [(open)], or [defaultOpen] | open + on_open_change, or default_open |
| Action | action | #action slot | <ng-template spAction> | — |
| Toaster | <SpToaster> around the toasts | <SpToaster> | <sp-toaster> | sp_toaster(*toasts) |
Props
SpToast
| React / Angular | Vue | Type | Description |
|---|---|---|---|
title required | title | string | The toast's first line. |
description | description | string | A line under the title. |
kind | kind | AlertKind | Default 'info'. |
duration | duration | number | ms, at least 1000, or Infinity; the toaster's when omitted. |
closeLabel | close-label | string | Default 'Dismiss'. |
SpToaster
| React / Angular | Vue | Type | Description |
|---|---|---|---|
position | position | 'bottom-end' | 'bottom-start' | 'top-end' | 'top-start' | Default 'bottom-end'. |
duration | duration | number | Default 5000 ms. |
label | label | string | Default '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 / Angular | Vue | Reflex | Type | Description |
|---|---|---|---|---|
id | id | id | str | The frame variant and every related id derive from it. |
ground | ground | ground | Literal['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. |
substrate | substrate | substrate | Literal['cream', 'green', 'blue', 'ochre', 'prussian'] | Prepared substrate within the ground. |
mode | mode | mode | Literal['ink', 'precision'] | ink by default; precision disables inking. |
seed | seed | seed | str | int | Seed of the frame's hand; overrides id for the frame variant only. |
size | size | size | Literal['sm', 'md', 'lg'] | Control size: sm, md (default) or lg. |
palette | palette | palette | dict[str, str] | Colours over the ground's (set with palette=), merged over the dashboard's and the provider's. |
className | class-name | class_name | str | Added to the component's root element, after its own classes. |
palette | palette | palette | Palette | Colours over the ground's, merged over the dashboard's and the provider's. |