Search the documentation

Type to search page titles, component names and descriptions.

    Feedback

    Toast

    Transient confirmation in a live region.

    import { Toast, ToastRegion } from 'faifo-design'

    Toast confirms something that just happened, or reports background work with its progress. ToastRegion is the live region that announces them.

    #When to use

    • Use it for a result that needs no decision: saved, sent, copied.
    • An error the reader must act on stays on the page as a Notice or a field error.

    #Examples

    Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.

    #Transient feedback and loading

    Live-region toasts (one reporting background work with progress), compact progress and content skeletons share state rules.

    Saving recordSaving record
    Record saved

    All changes are synchronized.

    Importing products

    products-october.csv · Started by Linh

    180 of 450 rows40%
    Show codeHide code
    import { Inline, Skeleton, Spinner, Stack, ToastRegion } from 'faifo-design'
    
    export const Example = () => (
      <Stack
        items={[
          <Inline items={[<Spinner label="Saving record" />, <span>Saving record</span>]} />,
          <Skeleton label="Loading customer summary" lines={3} />,
          <ToastRegion
            label="Notifications"
            toasts={[
              {
                id: 'saved',
                title: 'Record saved',
                message: 'All changes are synchronized.',
                tone: 'positive',
              },
              {
                id: 'importing',
                title: 'Importing products',
                message: 'products-october.csv · Started by Linh',
                tone: 'info',
                progress: { value: 40, label: '180 of 450 rows' },
              },
            ]}
          />,
        ]}
      />
    )

    #API

    Generated from the package source. A property without a description has none in the source yet.

    #ToastComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    titlerequired–string–
    message–string–
    tone–Tone'neutral'
    actions–JSXChild–
    progressHow far the work this toast reports has got, for work that runs in the background (an import). The bar and its label are not announced: a live region would read every update, so the title and message carry what a reader must hear (started, finished).{ value: number; label: string }–

    #ToastRegionComponent

    PropertyDescriptionTypeDefault
    labelrequired–string–
    toastsrequired–readonly ToastProps[]–

    #Types

    #ToastProps

    The properties of Toast, listed above.

    #Hooks

    The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.

    • toast-region
    • toast
    • toast-copy
    • toast-title
    • toast-message
    • toast-actions
    • toast-progress