Knob

A circular dial for a number in a range, with the value written inside: compact controls such as volume, gain or a thermostat.

  • vig-knob
Import
import { Knob } from '@vigdx/ui/knob';

Basic

Bind [(value)] to a number | null signal; min , max and step default to 0, 100 and 1. Drag around the dial or use the keyboard. An empty knob rests at min .

Volume

Value: 40

Formatting, steps and the wheel

formatValue is a function of the number that formats the text inside the dial and aria-valuetext ; without it the number is formatted for the active locale. Unlike vig-slider 's valueTemplate , which also takes a '{0} %' string template, it is a function only: new components take functions, not string templates. wheel lets the mouse wheel turn a focused knob (a step per notch; trackpad gestures add up to steps), so scrolling the page never changes a value.

Opacity

Temperature

Gain

Focus it, then scroll.

Sizes and states

size scales the dial with its font ( sm , md , lg ). readonly keeps it focusable but fixed; disabled knobs leave the tab order. Errors color the arc and show their message once touched.

Small

Large

Read-only

Disabled

Error

Keep it at 90 or below.

Signal Forms

vig-knob implements FormValueControl<number | null> . Schema min() and max() rules set the dial's range.

Fan speed

1 to 5

Valid: yes · 3

Reactive Forms

Import VigValueAccessor next to the component to use formControlName , [formControl] or ngModel .

Balance

0 · pristine

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="knob"][data-part="label"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="knob"]

Knob styling hooks
Part Element data-state
label The visible label ( aria-labelledby of the control). —
control The role="slider" dial wrapper. —
dial The SVG of the dial. —
track The full arc, in the control-boundary color. —
range The arc up to the value. —
thumb The marker at the value. —
value The formatted value inside the dial. —
hint The vig-hint (a display: contents host; style its text part). —
disabled-reason The vig-hint with the disabled reason ( display: contents ). —
error The vig-field-error (a display: contents host; style its message part). —

Accessibility

  • A role="slider" named by its label: Right and Up raise the value, Left and Down lower it, Page Up and Page Down move by a tenth of the range, Home and End jump to min and max. Under RTL the dial fills counter-clockwise and Left and Right swap, like a mirrored slider.
  • The text inside the dial is hidden from screen readers; the same text is announced through aria-valuetext, so put units in formatValue.
  • Pointer drags use pointer capture and touch-action: none on the dial only, so a drag never scrolls the page while the rest of the page scrolls as usual.
  • The value arc (--color-primary) holds 3:1 against the light track (--color-muted) and the track's --color-border-control border 3:1 against the page. Forced-colors mode draws the dial with system colors (Highlight on Canvas inside CanvasText). The focus outline follows the round dial.
  • The slider role has no aria-required, so required adds a visually hidden "Required" to the description. For exact numbers offer a number input too: dials are hard to set precisely.

API

Knob

vig-knob component

A circular dial for a number between min and max, in steps, with the value written inside (formatValue). Drag around the dial, or use the keyboard like a slider: arrows step (mirrored under RTL, where the dial fills counter-clockwise), Page Up/Down take ten steps' worth, Home and End jump to the ends. The mouse wheel is opt-in (wheel) and only turns a focused knob, so scrolling the page never changes a value.

Example :
<vig-knob label="Volume" [(value)]="volume" [formatValue]="percent" />

Sized with the font (size), colored with the kit's tokens: the value arc is --color-primary on a --color-muted track inside a --color-border-control border. Works with Signal Forms and, through VigValueAccessor, with Reactive Forms and ngModel.

Knob props
Name Type Default Description
dirtybooleanfalse
—
disabledbooleanfalse
—
disabledReasonsreadonly WithOptionalFieldTree<DisabledReason>[][]
—
errorMessagesRecord<string, string>—
—
errorsreadonly ValidationError.WithOptionalFieldTree[][]
—
formatValue((value: number) => string) | undefinedundefined

Formats the value inside the dial and for aria-valuetext, e.g. (n) => n + ' %'; the locale-formatted number by default.

hiddenbooleanfalse
—
hideLabelbooleanfalse

Keeps the label for assistive tech only.

hintstring | undefinedundefined
—
invalidbooleanfalse
—
label required string—
—
labelsPartial<KnobLabels>—

Texts (i18n); locale defaults.

maxnumber | undefined100
—
minnumber | undefined0
—
namestring''
—
pendingbooleanfalse
—
readonlybooleanfalse
—
requiredbooleanfalse
—
sizeFieldSize'md'
—
stepnumber1
—
touchedbooleanfalse
—
value model number | nullnull

The value, null while empty; an empty knob rests at min.

wheelbooleanfalse

Lets the mouse wheel turn the knob while it has focus.

Are you sure?