Skip to content

Form status

The result of a form's post, said where the form is.

<div data-mount="fail" id="sample-fail"></div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/form-status.css";

Usage

<p tabindex="-1" role="alert" class="cap-alert cap-form-status" data-tone="crit">
  <svg class="cap-status-glyph" aria-hidden="true">...</svg>
  <span class="cap-alert-body">The title is empty. Write a title, then save again.</span>
</p>
<p tabindex="-1" role="status" class="cap-alert cap-form-status" data-tone="ok">
  <svg class="cap-status-glyph" aria-hidden="true">...</svg>
  <span class="cap-alert-body">Your abstract was saved.</span>
</p>
<p tabindex="-1" role="status" class="cap-sr-only cap-form-status"></p>
import { FormStatus, useActionStatus } from "capsomer/react/form-status";
<FormStatus status={useActionStatus(actionData)} />

Examples

Saved

<div data-mount="ok" id="sample-ok"></div>

Before a post (empty, hidden, in the page)

<div data-mount="none" id="sample-none"></div>

API reference

FormStatus

PropTypeRequiredDoes
statusActionStatus | nullYesThe status to say, or null for none. A new object is a new result and takes focus.
focusFormStatusFocus
classNamestring

Functions

FunctionSignatureDoes
useActionStatus(data: unknown): ActionStatus | nullThe status of the action's answer, read with actionStatus, kept stable while the answer is the same object so focus moves once per post: <FormStatus status={useActionStatus(actionData)} />.

Parts and data attributes

ClassIs
.cap-form-statusthe root

Accessibility

KeyDoes
TabFrom the result, on into the form
  • Focus lands on the result after each post; its words are its name.
  • Screen readers: no manual NVDA or VoiceOver run, by decision (2026-11-07); the automated browser checks and a front-end review stand in. Automated: see the site's Tests page.