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

Button

The native push button in the four action tones; primary is the only filled button at rest, destructive fills on hover and always needs a confirmation or an undo.

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

Live variants

default

Markup
<j3w1-button id="example-button-default"><button class="button" type="button">
  <svg class="button-icon" aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M3 8.5l3 3 7-7"></path></svg>
  <span class="button-loading" aria-hidden="true">⋯</span>
  <span class="button-label">Save changes</span>
</button></j3w1-button>

secondary

Markup
<j3w1-button id="example-button-secondary"><button class="button button-secondary" type="button">
  <span class="button-loading" aria-hidden="true">⋯</span>
  <span class="button-label">Preview</span>
</button></j3w1-button>

tertiary

Markup
<j3w1-button id="example-button-tertiary"><button class="button button-tertiary" type="button">
  <span class="button-loading" aria-hidden="true">⋯</span>
  <span class="button-label">Cancel</span>
</button></j3w1-button>

destructive

Markup
<j3w1-button id="example-button-destructive"><button class="button button-destructive" type="button">
  <span class="button-loading" aria-hidden="true">⋯</span>
  <span class="button-label">Delete workspace</span>
</button></j3w1-button>

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/button.css';
import '@j3w1/ui/register/button';

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 button --out ./vendor/j3w1/button

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.
toneCustomEventButton tone: primary, secondary, tertiary or destructive.

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
j3w1-actionCustomEventA native button activated. Prevent default on this event to cancel the associated native default action.

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

Button button

  • Family: Actions
  • Maturity: stable
  • Priority: R1
  • Since: 0.1.0
  • Native control: native <button type="button"> — APG pattern
  • specified
  • demonstrated
  • test implemented

The native push button in the four action tones; primary is the only filled button at rest, destructive fills on hover and always needs a confirmation or an undo.

Report an issue with this component

Open component workbench

View source and copy recipe · Download standalone example

Tokens

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

PartRoleValueUse
root.bgcolor.action.primary.bgapproveduse#7d1310Primary button fill; D-026 darkened it off color12, which stays fixed as heritage ANSI 12.
root.textcolor.action.primary.textapproveduse#ffa2a7Primary action labels: bright rose across rest, hover and pressed states (D-033).
root.bordercolor.action.primary.borderobserveduse#9e231fPrimary button border.
root.bg-hovercolor.action.primary.hover-bgobserveduse#911410Primary button hover; pair with action.primary.text (D-033).
root.bg-activecolor.action.primary.pressed-bgobserveduse#630f0dPrimary button pressed.
root.ringcolor.interaction.focus.ring-containerobserveduse#ffa2a7Focus colour for containers and explicitly mapped filled controls (D-015); component rules determine ring geometry.
secondary.bgcolor.action.secondary.bgobservedusergb(0 0 0 / 0%)Secondary button has no fill.
secondary.textcolor.action.secondary.textapproveduse#ffa2a7D-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
secondary.bordercolor.action.secondary.borderapproveduse#986f72D-041 action.secondary.border: color.primitive.modern.control.
secondary.bg-hovercolor.action.secondary.hover-bgobserveduse#630f0dSecondary button hover.
secondary.bg-activecolor.action.secondary.pressed-bgobserveduse#420f0cSecondary button pressed.
secondary.ringcolor.interaction.focus.ringobserveduse#e539351px dashed focus ring on controls and rows.
tertiary.textcolor.action.tertiary.textapproveduse#e99499D-041 owner correction: rose is the default UI and reading foreground; near-white is reserved for document headings, highlights and contrast-critical fills.
tertiary.bg-hovercolor.action.tertiary.hover-bgobserveduse#1c0a09Ghost and icon button hover.
tertiary.bg-activecolor.interaction.pressed.bgobserveduse#420f0cPressed fill.
destructive.textcolor.action.destructive.textobserveduse#f07178D-041 destructive foreground remains readable on native warning tints.
destructive.bordercolor.action.destructive.borderobserveduse#e53935Destructive button border.
destructive.bg-hovercolor.action.destructive.hover-bgobserveduse#dc282eDestructive button hover fill.
destructive.text-hovercolor.action.destructive.hover-textobserveduse#f9faf9Destructive button text on hover (4.58:1).
destructive.bg-activecolor.action.destructive.pressed-bgobserveduse#ae1914Destructive button pressed fill.
destructive.bg-filledcolor.action.destructive.filled-bgobserveduse#dc282eConfirm-dialog destructive fill.
destructive.text-filledcolor.action.destructive.filled-textobserveduse#f9faf9Text on the destructive fill.
root.border-activecolor.action.primary.borderobserveduse#9e231fPrimary button border.
secondary.border-activecolor.border.activeobserveduse#e53935Active or focused control border.
tertiary.border-activecolor.border.activeobserveduse#e53935Active or focused control border.
destructive.border-activecolor.action.destructive.borderobserveduse#e53935Destructive button border.
root.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.
root.bg-disabledcolor.interaction.disabled.bgapproveduse#0d0707D-041 interaction.disabled.bg: color.primitive.modern.panel.
root.border-disabledcolor.border.disabledapproveduse#482b2bD-041 border.disabled: color.primitive.modern.divider.
loading.glyphcolor.action.primary.textapproveduse#ffa2a7Primary action labels: bright rose across rest, hover and pressed states (D-033).

State matrix

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

StatePrimarySecondaryTertiaryDestructive
default
hover
focus-visible
active
disabled
loading

Purpose

Triggers an action; navigation is a link. Four tones only, and one primary per view; secondary serves every other action, tertiary low-emphasis and toolbar actions. A destructive button also needs a confirmation step or an undo; the colour is not the safeguard.

Anatomy

The filled destructive modifier (.button-destructive-filled, color.action.destructive.filled-bg with color.action.destructive.filled-text) exists only inside confirm dialogs.

States

StateVisualNon-colour channel
defaultprimary: color.action.primary.bg fill, color.action.primary.text, 1px color.action.primary.border; secondary: 1px color.action.secondary.border, color.action.secondary.text; tertiary: color.action.tertiary.text, no border; destructive: 1px color.action.destructive.border, color.action.destructive.text—
hoverprimary → color.action.primary.hover-bg; secondary → color.action.secondary.hover-bg; tertiary → color.action.tertiary.hover-bg; destructive fills color.action.destructive.hover-bg with color.action.destructive.hover-textcursor: pointer; hover-capable pointers only
focus-visible1px dashed ring at −2px: color.interaction.focus.ring-container on the primary fill, color.interaction.focus.ring on the outline tones, color.action.destructive.hover-text on the destructive hover fillthe ring
activefill: primary color.action.primary.pressed-bg, secondary color.action.secondary.pressed-bg, tertiary color.interaction.pressed.bg, destructive color.action.destructive.pressed-bg; border: primary and destructive keep theirs, secondary and tertiary take color.border.active (D-015)border change on secondary and tertiary; no translation or scale
disabledcolor.text.disabled on color.interaction.disabled.bg, 1px color.border.disabled, every tone alike; no hover or active stylingdisabled; cursor: not-allowed; never opacity
loadingsize and tone unchanged; the static ⋯ glyph replaces the icon; stays focusable, ignores activationglyph; aria-busy

Precedence: disabled > loading > active > hover; focus-visible is always drawn.

Keyboard

Native; nothing else is bound. A loading button keeps its tab stop so focus is not lost mid-action.

Accessibility

The accessible name is the label; an icon-only button is icon-button. Never aria-disabled on a button that should be skipped. When a user needs to discover why an action is unavailable, keep the button enabled and explain on activation instead of disabling it. Text meets 4.5:1 and borders and rings 3:1 on every fill they sit on. Target at least 24×24 CSS pixels in compact, with 4px between neighbours.

Portability

Fill, border and outline express every state; no gradient, shadow or transform. A host without dashed outlines draws a solid 1px ring in the same colour and records the deviation; one that cannot recolour the ring on a fill draws it outside the fill at +1px.

Non-examples

Rounded or pill shapes. Two filled buttons in one view. A red filled destructive button at rest. A hover that only changes text colour. Translating or scaling on press. A spinner inside the button. Disabling with opacity. A <div> or <a> styled as a button. A gradient or shadow for depth.

Contrast report

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

PairStateKindForegroundBackgroundRatioMinResult
button default textdefaulttextcolor.action.primary.text #ffa2a7color.action.primary.bg #7d13105.574.5pass
button hover texthovertextcolor.action.primary.text #ffa2a7color.action.primary.hover-bg #9114104.754.5pass
button focus-visible textfocus-visibletextcolor.action.primary.text #ffa2a7color.action.primary.bg #7d13105.574.5pass
button focus-visible outlinefocus-visibleuicolor.interaction.focus.ring-container #ffa2a7color.action.primary.bg #7d13105.573pass
button active textactivetextcolor.action.primary.text #ffa2a7color.action.primary.pressed-bg #630f0d6.844.5pass
button loading textloadingtextcolor.action.primary.text #ffa2a7color.action.primary.bg #7d13105.574.5pass
primary fill against the panel (decorative; the label identifies the button)—uicolor.action.primary.bg #7d1310color.surface.default #0d07071.883waived: the fill is not the boundary of the control; the label text identifies it, and hover, active and focus each add a second channel
secondary text at rest—textcolor.action.secondary.text #ffa2a7color.action.secondary.bg #00000010.984.5pass
secondary border at rest—uicolor.action.secondary.border #986f72color.action.secondary.bg #0000004.853pass
secondary text on the hover fillhovertextcolor.action.secondary.text #ffa2a7color.action.secondary.hover-bg #630f0d6.844.5pass
secondary border against the panel while hovered (the fill inside it measures 2.94:1)hoveruicolor.action.secondary.border #986f72color.surface.default #0d07074.623pass
ring on the secondary hover fillhoveruicolor.interaction.focus.ring #e53935color.action.secondary.hover-bg #630f0d3.103pass
secondary text while pressedactivetextcolor.action.secondary.text #ffa2a7color.action.secondary.pressed-bg #420f0c8.414.5pass
tertiary text at rest—textcolor.action.tertiary.text #e99499color.action.secondary.bg #0000009.164.5pass
tertiary text on the hover fillhovertextcolor.action.tertiary.text #e99499color.action.tertiary.hover-bg #1c0a098.354.5pass
tertiary text while pressedactivetextcolor.action.tertiary.text #e99499color.interaction.pressed.bg #420f0c7.024.5pass
active border on the pressed fillactiveuicolor.border.active #e53935color.interaction.pressed.bg #420f0c3.813pass
destructive text at rest—textcolor.action.destructive.text #f07178color.action.secondary.bg #0000007.344.5pass
destructive border at rest—uicolor.action.destructive.border #e53935color.action.secondary.bg #0000004.973pass
destructive text on the hover fillhovertextcolor.action.destructive.hover-text #f9faf9color.action.destructive.hover-bg #dc282e4.584.5pass
ring on the destructive hover fill (the ring takes the on-fill colour)hoveruicolor.action.destructive.hover-text #f9faf9color.action.destructive.hover-bg #dc282e4.583pass
destructive text while pressedactivetextcolor.action.destructive.hover-text #f9faf9color.action.destructive.pressed-bg #ae19146.814.5pass
confirm-dialog filled destructive—textcolor.action.destructive.filled-text #f9faf9color.action.destructive.filled-bg #dc282e4.584.5pass
disabled 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+TabMoves focus to and from the button in document order.
Enter / SpaceActivates (native); Space activates on key up.

For agents

Component JSON ·Implementation brief ·Build a task kit ·

Related: icon-button link button-group segmented-control dialog

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