Navigated to /docs/ui/components/toast

Toast

Inline notification surface and fixed toast stack.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import the component from its dedicated entry point to keep the dependency and generated bundle explicit.

TSX
tsximport { Toast } from "@tavojs/ui/toast";

Normal Tavo.js applications load component styles through the Tavo.js UI plugin. If the application manages component CSS manually, also import @tavojs/ui/css/toast.

When to use

Use it when

Use `Toast` for transient notifications and `ToastStack` for fixed positioning

Choose something else when

Avoid Toast when using feedback components as primary page layout.

Examples

Toast example

TSX
tsximport { Toast } from "@tavojs/ui/toast";
import { ToastStack } from "@tavojs/ui";

export function ToastExample1() {
  const dismiss = () => undefined;
  return (
    <>
      <ToastStack>
        <Toast title="Saved" tone="success" onClose={dismiss}>Changes saved.</Toast>
      </ToastStack>
    </>
  );
}

Common props and defaults

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
titleChild

Configures title for this component.
tone"info" | "success" | "warning" | "danger"

Configures tone for this component.
actionChild

Configures action for this component.
onClose() => void

Configures onClose for this component.
closeLabelstring

Configures closeLabel for this component.

Complete TypeScript API

Import from @tavojs/ui/toast. Published exports: Toast, ToastProps, ToastStack, ToastTone.

ToastProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by Toast.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by Toast.

idstring

No

Inherited id attribute accepted by Toast.

rolestring

No

Inherited role attribute accepted by Toast.

styleRecord<string, unknown>

No

Inherited style attribute accepted by Toast.

titlestring & Child

No

Configures title for this component.

tabIndexnumber

No

Inherited tabIndex attribute accepted by Toast.

hiddenboolean

No

Inherited hidden attribute accepted by Toast.

disabledboolean

No

Inherited disabled attribute accepted by Toast.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by Toast.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by Toast.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by Toast.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by Toast.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by Toast.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by Toast.

toneToastTone

No

Configures tone for this component.

actionChild

No

Configures action for this component.

onClose() => void

No

Configures onClose for this component.

closeLabelstring

No

Configures closeLabel for this component.

State ownership and DOM target

ConcernContract
StateNo component state contract is exposed; the application owns the rendered content and surrounding behavior.
DOM targetPublic passthrough props target the component root. Treat nested elements and private class names as implementation details.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

Limitations

Avoid Toast when using feedback components as primary page layout.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Uses `role="status"`. Manage focus intentionally for destructive or blocking notifications.

  • Uses `role="status"`. Manage focus intentionally for destructive or blocking notifications.

Component status

ContractCurrent value
Maturitystable
Categoryfeedback
Component import@tavojs/ui/toast
Explicit CSS import@tavojs/ui/css/toast
PreviewInteractive preview available on this page