Knob
vig-knob
import { Knob } from '@vigdx/ui/knob';Basic
[(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 .
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.
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.
Signal Forms
vig-knob implements FormValueControl<number | null> . Schema min() and max() rules set the dial's range.
1 to 5
Valid: yes · 3
Reactive Forms
VigValueAccessor next to the component to use formControlName , [formControl] or ngModel .
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"]
| Part | Element | data-state |
|---|---|---|
label | aria-labelledby of the control). | — |
control | role="slider" dial wrapper. | — |
dial | — | |
track | — | |
range | — | |
thumb | — | |
value | — | |
hint | vig-hint (a display: contents host; style its text part). | — |
disabled-reason | vig-hint with the disabled reason ( display: contents ). | — |
error | 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 tominandmax. 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 informatValue. - Pointer drags use pointer capture and
touch-action: noneon 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-controlborder 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, sorequiredadds a visually hidden "Required" to the description. For exact numbers offer a number input too: dials are hard to set precisely.
API
Knob
vig-knobA 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.
<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.
| Name | Type | Default | Description |
|---|---|---|---|
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
formatValue | ((value: number) => string) | undefined | undefined | Formats the value inside the dial and for |
hidden | boolean | false | — |
hideLabel | boolean | false | Keeps the label for assistive tech only. |
hint | string | undefined | undefined | — |
invalid | boolean | false | — |
label | string | — | — |
labels | Partial<KnobLabels> | — | Texts (i18n); locale defaults. |
max | number | undefined | 100 | — |
min | number | undefined | 0 | — |
name | string | '' | — |
pending | boolean | false | — |
readonly | boolean | false | — |
required | boolean | false | — |
size | FieldSize | 'md' | — |
step | number | 1 | — |
touched | boolean | false | — |
value | number | null | null | The value, |
wheel | boolean | false | Lets the mouse wheel turn the knob while it has focus. |
| Name | Payload | Description |
|---|---|---|
touch | void | — |
valueChange | number | null | The value, |
| Signature | Description |
|---|---|
focus(options?: FocusOptions): void | Moves focus to the control's interactive element (the input, or the
trigger of a popup control). Signal Forms calls it through
|
reset(): void | Returns the control to its pristine look: drops in-progress text, closes
an open popup, clears errors the component raised itself and the
submitted state of |