Documentationv0.1.1

API reference

Methods exposed by sileo and the option types accepted by every toast.

View as Markdown

State methods

sileo.show(input, description?)
sileo.success(input, description?)
sileo.error(input, description?)
sileo.warning(input, description?)
sileo.info(input, description?)
sileo.action(input, description?)
sileo.loading(input, description?)

Each method accepts a title string or a SileoOptions object and returns the new toast id.

Lifecycle methods

sileo.update(id, options)
sileo.dismiss(id)
sileo.close(id)
sileo.clear(position?)

update accepts every SileoOptions field plus an optional state. clear can target one of the six positions.

Promise

sileo.promise<T>(
    promise: Promise<T> | (() => Promise<T>),
    options: SileoPromiseOptions<T>
): Promise<T>
type PromiseResult<T> = SileoOptions | ((data: T) => SileoOptions);

type SileoPromiseOptions<T> = {
    id?: string;
    loading: Pick<SileoOptions, 'title' | 'icon'>;
    error: SileoOptions | ((error: unknown) => SileoOptions);
    position?: SileoPosition;
} & ({ success: PromiseResult<T>; action?: undefined } | { action: PromiseResult<T>; success?: PromiseResult<T> });

Provide either success or action. If both are present, action becomes the final state.

Scoped defaults

const scoped = sileo.with(defaults);

The returned object has the same state, promise, update, dismiss, close, and clear methods. Call-level options override scoped defaults.

SileoOptions

FieldTypePurpose
titlestringPrimary notification text.
descriptionstring \| SnippetSupporting text or structured Svelte content.
positionSileoPositionViewport placement for this toast.
durationnumber \| nullLifetime in milliseconds. null keeps it open.
iconSnippet \| nullCustom icon content or no icon.
buttonSileoButtonOne labeled action with the toast id callback.
fillstringToast background color.
roundnessnumberCorner roundness used by the toast shape.
autopilotboolean \| objectAutomatic expand and collapse timing.
classesSileoClassesClass names for supported internal parts.
stylesSileoStylesTyped color values for supported internal parts.

Exported types

import type {
    SileoApi,
    SileoButton,
    SileoClasses,
    SileoInput,
    SileoOptions,
    SileoPosition,
    SileoPromiseOptions,
    SileoScopedApi,
    SileoState,
    SileoStyles
} from 'sileo-svelte';