Skip to content

ActionForm

A single-button POST form whose SubmitButton shows pending only for its own submission.

FormsIsland

Examples

Row action

Each form arms its own button on submit; only an armed button follows its frame's reloadStart/reloadComplete. Another row's submit or a sidebar link leaves it idle.

Example
<ActionForm
  action={routes.dashboard.servers.refresh.href({ id })}
  fields={{ return_to: serversHref }}
  resetScroll="manual"
  variant="ghost"
  size="sm"
  icon="refresh"
  pendingLabel="Refreshing…"
>
  Refresh
</ActionForm>

SubmitButton in a longer form, pending

Pending keeps the icon slot, swaps it for a spinner and shows the pending label. It is aria-disabled, never disabled.

Saving…
Example
<form method="post" action={routes.dashboard.servers.update.href({ id })}>
  {/* fields */}
  <SubmitButton icon="check" pendingLabel="Saving…">Save changes</SubmitButton>
</form>

Usage

Usage
import { ActionForm, SubmitButton } from '@switchboard/ui'

<ActionForm action={refreshHref} fields={{ return_to: listHref }} icon="refresh" pendingLabel="Refreshing…">
  Refresh
</ActionForm>

Props

Every component also takes mix, for css() and mixins applied after its own style.

ActionForm

ActionForm props
PropTypeDefaultDescription
action*string–Where the form posts.
fieldsRecord<string, string>–Hidden fields, e.g. { return_to }.
documentboolean–data-rmx-document: a full page submission (cross-origin redirects). Pending then starts on submit and resets on pageshow.
resetScroll'manual'–data-rmx-reset-scroll: keep the scroll position after the response.
formAttributesProps<"form">–Extra attributes for the form (id, data-*).

Every SubmitButton prop is passed to its button.

SubmitButton

SubmitButton props
PropTypeDefaultDescription
childrenstring–The label.
pendingLabelstring–Shown and announced (polite live region) while pending: "Saving…".
pendingboolean–Start pending. Normally unset: the form submission drives it.

A Button with type="submit". variant, size, icon, iconOnly, block, name, value, form and aria-label work as on Button.

Accessibility

  • Pending sets aria-busy and aria-disabled but never disabled, so focus stays on the button and its name/value still post.
  • The pending label is announced through a polite live region; aria-busy alone is not announced.
  • A second submit of the same form is cancelled while pending.

Guidance

Do

  • Use one ActionForm per row action.
  • Write the pending label as a present participle: "Refreshing…".

Don’t

  • Set disabled on submitters or fieldsets before a submission.
  • Show pending for every form on the page.