j3w1 / Segmented controlVue · HTML · React · Astro

J3W1 / DESIGN SYSTEM

Segmented control

A short exclusive choice implemented with labelled native radios.

stable · LIGHT DOM · 1.1.0

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

Live variants

default

View density

<j3w1-segmented-control id="example-segmented-control-default"><fieldset class="segmented-control radio-group radio-group-horizontal"><legend class="radio-group-legend">View density</legend><div class="segmented-control-options radio-group-options"><label class="radio-group-option"><span class="radio-group-control"><input class="radio-group-input" type="radio" name="example-segmented-control-default-density" value="compact" checked="" data-demo-focus-target=""><span class="radio-group-dot" aria-hidden="true"></span></span><span class="radio-group-text">Compact</span></label><label class="radio-group-option"><span class="radio-group-control"><input class="radio-group-input" type="radio" name="example-segmented-control-default-density" value="comfortable"><span class="radio-group-dot" aria-hidden="true"></span></span><span class="radio-group-text">Comfortable</span></label></div></fieldset></j3w1-segmented-control>

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@1.1.0
import '@j3w1/ui/tokens.css';
import '@j3w1/ui/styles/segmented-control.css';
import '@j3w1/ui/register/segmented-control';

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@1.1.0 j3w1-ui copy segmented-control --out ./vendor/j3w1/segmented-control

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: radio-group.

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

Purpose

Choose one value from a short labelled set using native radios. This changes a value; use tabs for associated content panels. Native names, required checks, disabled fieldsets and form reset are preserved.

Anatomy

  • fieldset: Legend names the choice.
  • options: Native radios sharing one name, each with a visible label.

States

StatePresentationNon-colour channel
defaultNamed content on the default surface.Native text and structure.
checkedSelected fill and a check indicator.Native checked state.
focus-visibleDashed focus ring.Native keyboard focus position.
disabledDisabled semantic foreground, background and border at full opacity.Native disabled state blocks activation.

Keyboard

  • Tab / Shift+Tab: Enter the native radio group once and leave it.
  • Arrow keys / Space: Use native radio selection and wrapping.

Accessibility

Keep native radios and labels. A checked value has both a visible native indicator and its programmatic checked state. Do not hide all radios from assistive technology or put role=tab on the labels.

Portability

Wrap labels and actions without changing source order. Use logical spacing in RTL. Preserve native target sizes at both densities; only bounded data regions may scroll horizontally. Use equivalent native semantics and approved roles; record any unsupported behavior as a mapping deviation. The host owns application data, persistence, permissions and services.

Non-examples

Unlabelled controls, color-only status, drag-only operations, hidden required instructions, stolen focus or an invented service success.

j3w1 / command

  • SPEC Overview
  • SPEC Foundations
  • SPEC Components
  • SPEC Patterns
  • SPEC Tokens
  • SPEC Tools
  • SPEC Implement
  • SPEC For agents
  • SPEC Ports
  • SPEC Releases
  • DEMO Vue application demo
  • SPEC Complete UI theme specification