Home / Function/ toast() — ui Function Reference

toast() — ui Function Reference

Architecture documentation for the toast() function in use-toast.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  30e47fbe_3f81_3b26_873e_26d9c29716e3["toast()"]
  0ac37ef4_ee03_7234_1fa3_be05404864ce["use-toast.ts"]
  30e47fbe_3f81_3b26_873e_26d9c29716e3 -->|defined in| 0ac37ef4_ee03_7234_1fa3_be05404864ce
  b292d328_7702_0bbd_4fe8_e2f03e0507ac["genId()"]
  30e47fbe_3f81_3b26_873e_26d9c29716e3 -->|calls| b292d328_7702_0bbd_4fe8_e2f03e0507ac
  4cadcb11_5cb9_1eed_a20f_6444ac24ea81["dispatch()"]
  30e47fbe_3f81_3b26_873e_26d9c29716e3 -->|calls| 4cadcb11_5cb9_1eed_a20f_6444ac24ea81
  style 30e47fbe_3f81_3b26_873e_26d9c29716e3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

deprecated/www/registry/default/hooks/use-toast.ts lines 145–172

function toast({ ...props }: Toast) {
  const id = genId()

  const update = (props: ToasterToast) =>
    dispatch({
      type: "UPDATE_TOAST",
      toast: { ...props, id },
    })
  const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id })

  dispatch({
    type: "ADD_TOAST",
    toast: {
      ...props,
      id,
      open: true,
      onOpenChange: (open) => {
        if (!open) dismiss()
      },
    },
  })

  return {
    id: id,
    dismiss,
    update,
  }
}

Subdomains

Frequently Asked Questions

What does toast() do?
toast() is a function in the ui codebase, defined in deprecated/www/registry/default/hooks/use-toast.ts.
Where is toast() defined?
toast() is defined in deprecated/www/registry/default/hooks/use-toast.ts at line 145.
What does toast() call?
toast() calls 2 function(s): dispatch, genId.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free