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

Icon button

A square ghost button whose only content is a 16px line icon; it always carries an accessible name and, as a toggle, aria-pressed.

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-icon-button id="example-icon-button-default"><button class="icon-button" type="button" aria-label="Close panel">
  <svg class="icon-button-icon" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="square"><path d="M3.5 3.5l9 9M12.5 3.5l-9 9"></path></svg>
</button></j3w1-icon-button>

toggle

Markup
<j3w1-icon-button id="example-icon-button-toggle"><button class="icon-button" type="button" aria-label="Pin window" aria-pressed="false">
  <svg class="icon-button-icon" aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="miter"><path d="M6 2h4v4l2 2v2H4V8l2-2z"></path><path d="M8 10v4"></path></svg>
</button></j3w1-icon-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/icon-button.css';
import '@j3w1/ui/register/icon-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 icon-button --out ./vendor/j3w1/icon-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

Icon button icon-button

  • Family: Actions
  • Maturity: stable
  • Priority: R1
  • Since: 0.1.0
  • Native control: native <button> with aria-label; aria-pressed for the toggle — APG pattern
  • specified
  • demonstrated

A square ghost button whose only content is a 16px line icon; it always carries an accessible name and, as a toggle, aria-pressed.

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.bgcolor.action.secondary.bgobservedusergb(0 0 0 / 0%)Secondary button has no fill.
root.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.
root.bg-hovercolor.action.tertiary.hover-bgobserveduse#1c0a09Ghost and icon button hover.
root.bg-activecolor.interaction.pressed.bgobserveduse#420f0cPressed fill.
root.border-activecolor.border.activeobserveduse#e53935Active or focused control border.
root.ringcolor.interaction.focus.ringobserveduse#e539351px dashed focus ring on controls and rows.
root.bg-toggledcolor.interaction.selection.bgapproveduse#531310Selected row, tab, workspace; D-027 recessed the fill, leaving the 2px indicator and the check to carry selection.
root.text-toggledcolor.interaction.selection.textobserveduse#f4eeeeText on the selection.
root.border-toggledcolor.border.selected-indicatorobserveduse#e539352px indicator bar on the selected tab or nav item.
root.ring-toggledcolor.interaction.focus.ringobserveduse#e539351px dashed focus ring on controls and rows.
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.
icon.strokecolor.icon.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.

State matrix

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

StateActionToggle
default
hover
focus-visible
active
disabled
toggled
toggled+focus-visible

Purpose

The tertiary tone in a square, for toolbar actions, close and clear affordances and boolean toggles such as pin, mute or wrap. If the label must be visible, use button.

Anatomy

Parts as listed in the anatomy.

States

StateVisualNon-colour channel
defaultcolor.action.tertiary.text icon, no fill; transparent 1px border—
hoverbackground → color.action.tertiary.hover-bgcursor: pointer; hover-capable pointers only
focus-visible1px dashed ring color.interaction.focus.ring at −2pxthe ring
activebackground → color.interaction.pressed.bg; border → color.border.activeborder change; no translation
disabledcolor.text.disabled on color.interaction.disabled.bg, 1px color.border.disabled; no hoverdisabled; cursor: not-allowed
toggledcolor.interaction.selection.bg fill, color.interaction.selection.text, border color.border.selected-indicator; filled icon formaria-pressed="true"; the filled icon shape; the border
toggled+focus-visiblethe selection fill and 1px dashed color.interaction.focus.ring at −2pxboth visible at once

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

Keyboard

Native; the toggle does not move focus. In a toolbar the host applies roving tabindex; the button binds nothing.

Accessibility

Every icon button has an accessible name (aria-label or aria-labelledby) and a tooltip that repeats it but is not the name. The SVG is aria-hidden="true" and focusable="false". The name never changes with the state (“Mute”, not “Mute” / “Unmute”). The icon meets 4.5:1 and rings 3:1 on every fill. Target at least 24×24 CSS pixels in compact, with 4px between neighbours.

Portability

Square, fill, border and outline; the currentColor icon follows every state. A host without inline SVG uses its icon theme at 16px and records the substitution; one without dashed outlines draws a solid 1px ring.

Non-examples

A circle. No accessible name. A toggle that changes its label instead of aria-pressed. A hover that recolours only the icon. An emoji or icon-font glyph instead of the SVG. A toggled state shown by colour alone with a line icon. A shadow or scale on press.

Contrast report

13 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
icon-button default textdefaulttextcolor.action.tertiary.text #e99499color.action.secondary.bg #0000009.164.5pass
icon-button hover texthovertextcolor.action.tertiary.text #e99499color.action.tertiary.hover-bg #1c0a098.354.5pass
icon-button focus-visible textfocus-visibletextcolor.action.tertiary.text #e99499color.action.secondary.bg #0000009.164.5pass
icon-button focus-visible outlinefocus-visibleuicolor.interaction.focus.ring #e53935color.action.secondary.bg #0000004.973pass
icon-button active textactivetextcolor.action.tertiary.text #e99499color.interaction.pressed.bg #420f0c7.024.5pass
icon-button active borderactiveuicolor.border.active #e53935color.interaction.pressed.bg #420f0c3.813pass
icon-button toggled texttoggledtextcolor.interaction.selection.text #f4eeeecolor.interaction.selection.bg #53131012.474.5pass
icon-button toggled+focus-visible texttoggled+focus-visibletextcolor.interaction.selection.text #f4eeeecolor.interaction.selection.bg #53131012.474.5pass
icon-button toggled+focus-visible outlinetoggled+focus-visibleuicolor.interaction.focus.ring #e53935color.interaction.selection.bg #5313103.383pass
toggled border against the paneltoggleduicolor.border.selected-indicator #e53935color.surface.default #0d07074.733pass
toggled fill against the panel (decorative)toggleduicolor.interaction.selection.bg #531310color.surface.default #0d07071.403waived: aria-pressed, the filled icon form and the 1px selected-indicator border carry the state; the fill is not the boundary
disabled icon (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.
Enter / SpaceActivates; the toggle variant flips aria-pressed.

For agents

Component JSON ·Implementation brief ·Build a task kit ·

Related: button toolbar tooltip segmented-control

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