useInputStatusIcon@astryxdesign/core v0.7.8 · useInputStatusIcon

Usage

Builds the on-field status affordance for a bordered input and its accessibility wiring, so every input in the family behaves the same for a given status. The attached variant renders a plain glyph and leaves the text to the message box; the detached variant renders nothing here, because the message box already carries its own icon; the tooltip variant renders a real focusable button whose tooltip is reachable by keyboard, pointer, touch and assistive tech. Use it when building a bordered input, not for field-level messaging.

ts
import {useInputStatusIcon} from '@astryxdesign/core/hooks'

Best practices

GuidancePractices
Do

Render statusIcon inside the input container and merge describedBy into the control's aria-describedby list.

Do

Let it decide when nothing should render; pass isInGroup and the variant through rather than branching at the call site.

Don't

Use it to convey the status by icon alone; the tooltip variant is the only one that carries the message, so the others still need a message box.

Parameters

ParamTypeDescription
optionsrequired

Configuration object.

options.status

The input's status (type plus message), or undefined when there is none.

options.statusVariant
'attached' | 'detached' | 'tooltip' (default: 'attached')

How the status is presented relative to the input.

options.isInGroup
boolean (default: false)

Whether the input sits inside an InputGroup, which owns status rendering itself.

options.size
(default: 'md')

Size of the on-field icon.

Returns

FieldTypeDescription
statusIconReactNode

The affordance to render inside the input container: a plain icon, or a focusable info-tip button with its tooltip. Null when no icon should render.

describedBystring | undefined

ID to add to the input's aria-describedby, present exactly when a tooltip element is in the DOM, so there is never a dangling reference.

Examples

Common configurations, variations, and states.
useInputStatusIcon — Coupon Code Status
Open in Playground

A custom bordered coupon-code input whose status affordance comes from useInputStatusIcon. A wrong code shows the error status and SAVE20 shows success. Switching the variant moves between a plain glyph with a message below (attached), no icon on the field (detached), and a focusable button whose tooltip keyboard and screen-reader users can reach, with its aria-describedby id returned by the hook (tooltip).

Use with shadcn

Already using the shadcn registry workflow? Install the real Astryx package and a local public re-export. Component implementation source stays in Astryx.

This install URL expires with the draft preview.
bash
npx shadcn@4.19.0 add https://astryx-quxrop0ob-fbopensource.vercel.app/shadcn/hooks/use-input-status-icon.json