j3w1 / theme

j3w1 / theme4.0.0

j3w1 / command

  • SPEC Overview
  • SPEC Foundations
  • SPEC Components
  • SPEC Patterns
  • SPEC Tokens
  • SPEC Tools
  • SPEC Workbench
  • SPEC Form builder
  • SPEC Task kit
  • SPEC Recipes
  • SPEC Figma bridge
  • SPEC Report an issue
  • SPEC Implement
  • SPEC For agents
  • SPEC Ports
  • SPEC Releases
  • SPEC Specification
  • DEMO Vue application demo

Field

The label, control, help and message wrapper that every form control sits in; it fixes the stacking order, the required mark, the description links and the invalid message.

stable · light DOM · 4.0.0. Light DOM retains static content, native semantics, label relationships and host composition without duplicating controls.

Live variants

default

Letters, digits and hyphens; shown in the bar.

✕ Hyphens cannot start or end the name.

Markup
<j3w1-field id="example-field-default"><div class="field">
  <label class="field-label" for="example-field-default-fd-host">Host name <span class="field-required" aria-hidden="true">*</span><span class="field-required sr-only"> required</span></label>
  <div class="field-control">
    <input class="field-input" id="example-field-default-fd-host" type="text" value="workstation" aria-describedby="example-field-default-fd-host-help example-field-default-fd-host-message" name="example-field-default-fd-host">
  </div>
  <p class="field-help" id="example-field-default-fd-host-help">Letters, digits and hyphens; shown in the bar.</p>
  <p class="field-message" id="example-field-default-fd-host-message">✕ Hyphens cannot start or end the name.</p>
</div></j3w1-field>

Install and register

Use the exact version. If npm publication is pending, install the release tarball from the installation guide.

npm install --save-exact @j3w1/ui@4.0.0
import '@j3w1/ui/tokens.css';
import '@j3w1/ui/styles/field.css';
import '@j3w1/ui/register/field';

Insert the maintained markup above after loading these imports. Its native children provide accessible names and form behavior; the empty custom tag alone does not create a control.

Vue SFC, React, Astro and plain HTML integration →

Copy the complete implementation

npx --package=@j3w1/ui@4.0.0 j3w1-ui copy field --out ./vendor/j3w1/field

The CLI verifies every file before writing and refuses overwrites. Serve the output over HTTP and open index.html. Keep its modules, CSS, tokens and licence notices together.

Public API

attributes

NameType / signatureMeaning
disabledCustomEventDisable the native controls owned by this instance.
loadingCustomEventMark the primary control busy and prevent duplicate activation.

properties

NameType / signatureMeaning
disabledbooleanDelegates disabled state to native children.
namestringNative control name; application form keys remain explicit.

methods

NameType / signatureMeaning
refresh(): voidReconnect behavior after replacing native child structure.
focus(options?: FocusOptions): voidFocus the first usable native control.

events

NameType / signatureMeaning

Dependencies and verification

Registered components: none. Style dependencies: none.

Package presence establishes an available implementation. Actual passes depend on the tested artifact and environment. Read specification execution evidence; read packed-consumer evidence; inspect the complete state matrix.

Full implementation manifest, API and token dependency closure

Canonical specification

Field field

  • Family: Basic forms
  • Maturity: stable
  • Priority: R1
  • Since: 0.1.0
  • Native control: native <label for> with aria-describedby on the control — APG pattern
  • specified
  • demonstrated

The label, control, help and message wrapper that every form control sits in; it fixes the stacking order, the required mark, the description links and the invalid message.

Report an issue with this component

Tokens

Focus a role to inspect its values; follow its link for persistent usage and source details.

PartRoleValueUse
root.textcolor.text.defaultapproveduse#e99499D-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
label.textcolor.text.brightapproveduse#ffa2a7D-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
label.required-markcolor.status.danger.textobserveduse#f07178D-041 readable error text on neutral surfaces and native warning tints.
control.bgcolor.surface.inputapproveduse#000000Form-control fill.
control.bordercolor.border.controlapproveduse#c81a1aD-041 owner correction: red control and floating-frame borders, distinct from rose text.
control.border-invalidcolor.status.danger.borderobserveduse#e53935Danger border, 2px on invalid inputs.
control.text-disabledcolor.text.disabledapproveduse#a3676bD-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
control.bg-disabledcolor.interaction.disabled.bgapproveduse#0d0707D-041 interaction.disabled.bg: color.primitive.modern.panel.
control.border-disabledcolor.border.disabledapproveduse#482b2bD-041 border.disabled: color.primitive.modern.divider.
help.textcolor.text.mutedapproveduse#d4868bD-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
message.textcolor.status.danger.textobserveduse#f07178D-041 readable error text on neutral surfaces and native warning tints.

State matrix

Every declared state and combination, statically rendered; the default cell is live. Sizes: compact, comfortable (switch with the density control above).

StateDefault
default

Letters, digits and hyphens; shown in the bar.

✕ Hyphens cannot start or end the name.

required
invalid
disabled

Purpose

Gives every control the same label, description and error treatment: the control specifies its box, the field what sits above and below it and how they are linked. Every form control renders inside a field or a fieldset.

Anatomy

Parts as listed in the anatomy.

States

StateVisualNon-colour channel
defaultlabel color.text.bright; help color.text.muted; control as its own component—
required* after the label in color.status.danger.text plus visually hidden “required”required attribute; the mark
invalidthe control’s 2px color.status.danger.border; message with the ✕ glyph in color.status.danger.text; help visually hiddenborder width 1 → 2px; glyph; aria-invalid
disabledlabel and control text color.text.disabled; control color.interaction.disabled.bg, 1px color.border.disabled; help unchangeddisabled; cursor: not-allowed

Precedence: disabled > invalid; required is shown in every state.

Keyboard

Adds no behaviour; clicking the label focuses the control (native for).

Accessibility

Every control has a programmatic label; placeholder text is never the label. The message keeps its glyph, so the state is not colour-only. Text meets 4.5:1; disabled text is exempt, with a house floor of 3:1.

Portability

No pseudo-elements: the required mark is real markup. Hosts without aria-describedby put help and message in the control’s tooltip or accessible description and record it.

Non-examples

A floating label inside the control. A label left of the control. Placeholder as the only label. An error shown by a red border alone. A message that replaces the help in the DOM. A colour-only required mark. An asterisk with no text alternative. Two controls in one field.

Contrast report

8 declared pairs measured on resolved sRGB values with the WCAG 2.x formula; 0 waived (decorative only), 0 failing. A pass is a design target for the named role, not an application-wide conformance claim.

PairStateKindForegroundBackgroundRatioMinResult
field default textdefaulttextcolor.text.bright #ffa2a7color.surface.default #0d070710.454.5pass
field required textrequiredtextcolor.status.danger.text #f07178color.surface.default #0d07076.984.5pass
field invalid textinvalidtextcolor.status.danger.text #f07178color.surface.default #0d07076.984.5pass
help text on the panel surface—textcolor.text.muted #d4868bcolor.surface.default #0d07077.224.5pass
help text on the canvas—textcolor.text.muted #d4868bcolor.surface.canvas #0000007.584.5pass
disabled label (exempt; house floor 3:1)disableduicolor.text.disabled #a3676bcolor.surface.default #0d07074.483pass
disabled control text (exempt; house floor 3:1)disableduicolor.text.disabled #a3676bcolor.interaction.disabled.bg #0d07074.483pass
disabled border (exempt)disableduicolor.border.disabled #482b2bcolor.interaction.disabled.bg #0d07071.581pass

Keys

KeyAction
Tab / Shift+TabReaches the control; the label is not a tab stop.

For agents

Component JSON ·Implementation brief ·Build a task kit ·

Related: text-field textarea select checkbox radio-group fieldset number-field search-field

Stress fixtures: FX-LONG FX-320 FX-ZOOM-200 FX-I18N FX-RTL FX-RM FX-HC FX-DENSITY FX-STATE-MATRIX