Hewn
Components

Components

Toast

Motion-aware notification stack with global provider.

newfree

Install

@hewnui/ui · hewnui

Terminal
npm install @hewnui/ui
Terminal
pnpm add @hewnui/ui
Terminal
yarn add @hewnui/ui
Terminal
bun add @hewnui/ui
Terminal
npx hewnui@latest add toast

Toasts stack from the corner with a tone well, lifetime bar, and dismiss control. Tones: default, success, danger, warning, and info. Reduced motion softens entrance and freezes the lifetime bar.

Usage

TSX
import { Button, ToastProvider, useToast } from "@hewnui/ui";

function Notify() {
  const { toast } = useToast();
  return (
    <Button
      onPress={() =>
        toast({ title: "Draft saved", tone: "success" })
      }
    >
      Notify
    </Button>
  );
}

Wrap the app with ToastProvider once — already included in the docs shell.

Tones

ToneUse
defaultNeutral status
successCompleted save or sync
dangerFailure that needs attention
warningSoft risk or quota pressure
infoTip or non-blocking guidance

Accessibility

  • danger toasts render role="alert" with aria-live="assertive"; every other tone uses role="status" with aria-live="polite", so routine confirmations never interrupt
  • The dismiss control is a real button labelled "Dismiss notification"
  • The countdown bar is aria-hidden and freezes when motion is off
  • Toasts auto-dismiss after 4200ms by default. Raise duration for longer messages, and do not put an action's only affordance inside a toast — the timer does not pause on hover or focus.

A toast is the wrong home for anything the user must act on. For blocking errors or decisions, use an inline message or a Dialog, which stay on screen until dismissed.

API reference

Props for Toast from @hewnui/ui/toast. Generated from component types — not hand-written.

Prop

Type

On this page