Skip to Content
ARCUI

Toast

Provider-owned imperative transient-message API with placement, duration, stacking, safe-area positioning, and programmatic dismissal.

Toast is an imperative ARCUI feedback API rather than a visual component import. The mounted ARCUI provider owns lifecycle, stacking, placement, safe area, motion, and accessibility announcement behavior.

Usage

import { showToast } from "react-native-arc-ui";

showToast({
  message: "Changes saved",
});

ARCUI must be mounted before showToast() / hideToast() are called. Calling the API without an active provider throws clearly.

Returned ID and early dismissal

showToast returns a stable TToastId:

import { hideToast, showToast } from "react-native-arc-ui";

const id = showToast({ message: "Uploading…" });

hideToast(id);

Unknown or already-closing IDs are intentionally a no-op. hideToast requests the normal exit lifecycle rather than tearing the item out mid-transition.

Message invariant

message is both visible content and the semantic announcement. It must be a non-empty string containing non-whitespace content.

showToast({ message: "Saved" }); // valid

Empty/whitespace-only messages are fundamental semantic misuse and throw instead of creating inaccessible feedback.

Placement

showToast({
  message: "Connection restored",
  placement: "top",
});

Supported placements:

top | bottom

When omitted, ARCUI uses tokens.toastAnimations.placement. Malformed dynamic placement values report in development and safely fall back to bottom.

Top and bottom maintain independent visible stacks.

Duration

showToast({
  message: "Saved",
  duration: 1800,
});

Duration is milliseconds:

undefined -> tokens.toastAnimations.displayDuration
0         -> request immediate dismissal
>= 0      -> explicit display lifetime

Invalid runtime values report in development and fall back to the configured display duration.

Icon content

showToast({
  message: "Saved",
  icon: <Icon type="check" color="white" />,
});

icon is decorative consumer content. ARCUI hides the icon slot from the accessibility tree because the message owns Toast semantics.

Stacking and capacity

The provider measures mounted Toast heights and calculates stack offsets so newest feedback is anchored closest to the configured screen edge.

Relevant sizing behavior includes:

maxVisibleItemsPerPlacement
stackOverlap
stackGap
stackScaleStep
stackMinScale

Capacity is enforced per placement. When a stack exceeds its configured visible capacity, the oldest entries for that placement are evicted.

Safe area

Top/bottom stacks use provider system insets resolved through tokens.safeArea.toast. Toast therefore follows the same ARCUI safe-area source as the rest of the library rather than introducing a direct safe-area dependency.

Multiple ARCUI providers

ARCUI is normally mounted once. If multiple providers temporarily exist during development/tests/navigation transitions, the most recently mounted provider owns the imperative Toast API. This keeps global calls deterministic.

Do not intentionally build application architecture around multiple competing Toast roots.

Testing

showToast({
  message: "Saved",
  testID: "save-toast",
});

Stable IDs:

save-toast
save-toast-message

The icon is consumer-owned and does not receive an ARCUI-generated test suffix.

API Reference

PropTypeDefaultDescription
messagestringrequiredVisible and announced Toast message. Must contain at least one non-whitespace character. Empty or whitespace-only messages are semantic API misuse and throw.
icon?ReactNode—Optional decorative content rendered before the message. Toast accessibility semantics are owned by message. Decorative icon content is intentionally hidden from the accessibility tree.
duration?number—Time in milliseconds before the Toast begins its normal exit lifecycle. Must be a finite non-negative number. 0 requests immediate dismissal. When omitted, ARCUI uses tokens.toastAnimations.displayDuration. Invalid runtime values report in development and safely fall back to the configured display duration.
placement?TToastPlacement—Screen edge used by this Toast. When omitted, ARCUI uses tokens.toastAnimations.placement. Malformed runtime JavaScript values report in development and safely degrade to the bottom placement.
testID?string—Deterministic native root identifier for automation. The message descendant uses `${testID}-message`.

Generated from the ARCUI 1.1.x TypeScript source snapshot. Native inherited props remain available through the referenced React Native surface.

Imperative functions:

showToast(input: TToastInput): TToastId
hideToast(id: TToastId): void

Motion

Toast separates item lifecycle motion from stack reflow motion:

  • enter/exit opacity + directional translation share one lifecycle progress;
  • sibling stack position/scale/border transitions use independent SharedValues;
  • active animations are cancelled before retargeting;
  • Reduced Motion snaps stack/lifecycle visuals to their target state.

That separation lets a Toast reverse/close while neighboring items reflow without coupling unrelated motion dimensions.

Performance

Timers are provider lifecycle work, not frame-by-frame React animation. React state owns the Toast entries/measured heights; Reanimated owns continuous enter/exit and stack interpolation.

Height updates are ignored when unchanged within a small tolerance to avoid unnecessary provider state churn.

Accessibility

message is the single semantic Toast payload. On Android the item uses live-region behavior; on iOS ARCUI explicitly queues the message announcement when it becomes semantically visible.

Decorative stack layers and icon content are hidden from accessibility to avoid duplicate announcements.

Theming

Relevant token areas include:

colors.*.toast
sizings.toast
radius.toast
typography.toast
toastAnimations
safeArea.toast
zIndex.toast
animations

Try it live

Explore Toast interactively in Expo Snack.

Open Toast in Expo Snack ↗

On this page