Ark Logo

Toast

A message that appears on the screen to provide feedback on an action.

Anatomy

To set up the toast correctly, you'll need to understand its anatomy and how we name its parts.

Each part includes a data-part attribute to help identify them in the DOM.

Examples

To use the Toast component in your application, you need to set it up using the createToaster hook. This hook manages the placement and grouping of toasts, and provides a toast object needed to create toast notification.

To create a basic Toast, use the toast.create method to display a notification.

import { XIcon } from 'lucide-solid'
import { Toast, Toaster, createToaster } from '@ark-ui/solid'

export const Basic = () => {
  const toaster = createToaster({
    placement: 'bottom-end',
    gap: 24,
  })

  return (
    <div>
      <button
        type="button"
        onClick={() =>
          toaster.create({
            title: 'Loading!',
            description: 'We are loading something for you. Please wait.',
            type: 'info',
          })
        }
      >
        Add Toast
      </button>
      <Toaster toaster={toaster}>
        {(toast) => (
          <Toast.Root>
            <Toast.Title>{toast().title}</Toast.Title>
            <Toast.Description>{toast().description}</Toast.Description>
            <Toast.CloseTrigger>
              <XIcon />
            </Toast.CloseTrigger>
          </Toast.Root>
        )}
      </Toaster>
    </div>
  )
}

Update Toast

Example not found

API Reference

ActionTrigger

PropDefaultType
asChild
(props: ParentProps<'button'>) => Element

CloseTrigger

PropDefaultType
asChild
(props: ParentProps<'button'>) => Element

Description

PropDefaultType
asChild
(props: ParentProps<'div'>) => Element

Title

PropDefaultType
asChild
(props: ParentProps<'div'>) => Element

Toaster

PropDefaultType
toaster
CreateToasterReturn

asChild
(props: ParentProps<'div'>) => Element