StatusHint
A one-line hint that states the outcome of an action.
Installation
pnpm add @talex-touch/tuffex
import { TxStatusHint } from '@talex-touch/tuffex/status-hint'
import '@talex-touch/tuffex/status-hint/style.css'
// It renders TxTextTransformer (which renders TxTextMorph) and TxIcon, whose sheets are separate
import '@talex-touch/tuffex/text-transformer/style.css'
import '@talex-touch/tuffex/text-morph/style.css'
import '@talex-touch/tuffex/icon/style.css'
import '@talex-touch/tuffex/base.css' // tokens + resets, once per app
Usage
Basic
A new message morphs out of the old words; when the same message arrives again, a new pulseKey replays the emphasis.
Loading demo...
Tones and Sizes
tone colors only the wash and the icon; md is a status line of its own, and sm sits in a toolbar or header.
Loading demo...
Placement
To lay the hint flush along a bar, position it with a class heavier than one class (a scoped class is enough) and set two CSS variables.
Loading demo...
Best Practices
- Keep it mounted while messages change: no
:keyper message, andv-ifonly for "no message", inside<Transition name="tx-status-hint">. - Pass each message's id as
pulseKey, or the same text arriving twice makes the second action look like it did nothing. - Keep it to one line of two to four words; it never wraps, so put long detail, such as a provider's error text, where it can wrap.
- When the hint mounts with its message, or the host already has an announcer, pass
live=falseand announce from an always-mountedrole="status"region; never putroleoraria-liveon the component, since attributes fall through to the rootdiv. - Use one hint per surface; when messages must queue, stack, or time out, use Toast.
API Reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
text | string | number | - | Required; one short line. While animated, a new value morphs out of the old one. |
tone | 'success' | 'warning' | 'danger' | 'info' | 'muted' | 'success' | Color of the wash and icon, reusing StatusTone; info reads the primary hue. |
size | 'sm' | 'md' | 'md' | md: 13px words, 16px icon; sm: 12px words, 14px icon. |
pulseKey | string | number | - | Replays the emphasis when it changes after mount; pass each message's id. |
animated | boolean | true | false shows the end state with plain text; wire the host's own motion switch here. |
live | boolean | true | true makes the words a polite live region; false leaves no live region in the component. |
Slots
| Slot | Description |
|---|---|
icon | Replaces the tone icon in the same aria-hidden box and motion; the only way to give muted an icon. |
CSS Variables
| Variable | Default | Description |
|---|---|---|
--tx-status-hint-radius | 8px | Corner radius of the hint and its wash; 0 for a flush placement. |
--tx-status-hint-pad-x | 10px; sm 8px | Inline padding, and the width of the end fade. |
--tx-status-hint-accent | the tone's colour | Color of the wash and icon, set by the tone; muted uses --tx-text-color-secondary. |
--tx-status-hint-wash-strength | 0.26; 0.2 under a dark theme | Wash alpha at the left edge; 0.45 of it at 38%, none at the right end. |
- The component never sets
--tx-status-hint-radius, so a rule on the hint or any ancestor applies; override--tx-status-hint-pad-xwith a rule heavier than one class. - Override
--tx-status-hint-accentand--tx-status-hint-wash-strengthwith an inlinestyleor a selector heavier than two classes. --tx-status-hint-pad-y,--tx-status-hint-icon-size,--tx-status-hint-spring, and--tx-status-hint-spring-durationare set by the component; hosts leave them alone.
Overview
- The words are
--tx-text-color-primaryat weight 600 in every tone;mutedis a neutral grey with no default icon. - It never wraps or adds an ellipsis: at most as wide as its container, a longer value fades into the end padding and is clipped.
- On mount the wash rises from the left edge and the icon and words land on a spring, readable from the first frame; a
textorpulseKeychange replays the emphasis, once per update. - A
textchange morphs the words character by character (380ms), resizing an inline hint; on leave the words fade first and the wash follows, opacity only. animated=falseandprefers-reduced-motion: reduceboth show the end state; under reduced motion alone the morph engine stays mounted and writes new values directly.- The wash, grain, and end fade are drawn left to right physically; right-to-left pages are not mirrored.
Technologies
- The wash is the tone's color behind a mask: a gradient intersected with a 140px
feTurbulencenoise tile throughmask-composite: intersect, and absent where unsupported; replays alternate two identical keyframe sets,is-pulse-aandis-pulse-b. - The spring is
resolveTransition('bouncy')fromliquid/src/spring.ts, written after mount; server markup falls back to620ms cubic-bezier(0.34, 1.56, 0.64, 1), and hydration matches. - Source:
packages/tuffex/packages/components/src/status-hint/;StatusTonecomes fromstatus-badge.
查看源码
packages/tuffex/packages/components/src/status-hint/index.ts
Use cases
- The outcome of an action, shown where it happened: "Copied", "Pinned", "Could not pin".
- CoreBox's action feedback, in its footer, or in its header when the footer is not showing.
Related components
- Toast: global notifications drawn by one host that stack and time out.
- Alert: an inline banner with a title, body, and close button, announced with
role="alert". - StatusBadge: a status pill that stays on screen; StatusHint reuses its
StatusTone. - TextTransformer: the text engine behind the hint's words.