Knob

Pick a number by turning a dial.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrKnob } from 'ngwr/knob';

@Component({ imports: [WrKnob] })
export class MyComponent {}

Basic

Bind a number with [(value)] or any Angular form.

<wr-knob [(value)]="value" [min]="0" [max]="100" suffix="%" />
45
70%

Size and stroke

size is the diameter and strokeWidth the arc thickness, both numbers in px.

<wr-knob [(value)]="value" [size]="64" [strokeWidth]="5" />
<wr-knob [(value)]="value" [size]="160" [strokeWidth]="14" />
45
45
45

Without the readout

[showValue]="false" hides the number; give the knob an ariaLabel.

<wr-knob [(value)]="volume" [showValue]="false" ariaLabel="Volume" />

Read-only and disabled

Read-only keeps its tab stop and refuses changes; disabled leaves the tab order.

<wr-knob [value]="62" readonly ariaLabel="Read-only" />
<wr-knob [value]="62" disabled ariaLabel="Disabled" />
62
62

Keyboard

Arrows move one step, Shift + arrow ten steps, Home / End jump to the ends.

API

NameDescriptionTypeDefault
ariaLabelAccessible name — the role needs one. Falls back to knob.label.string | nullnull
minMinimum allowed value.number | undefined0
maxMaximum allowed value.number | undefined100
stepStep granularity.number1
sizeDial diameter in CSS pixels.number120
strokeWidthStroke width of the dial arc, in CSS pixels.number8
trackColorTrack (unfilled) color.stringcolor-mix(in srgb, var(--wr-border-base) 60%, transparent)
valueColorFilled-arc color.stringvar(--wr-color-primary)
showValueShow the value text in the center.booleantrue
suffixOptional suffix appended to the center text (e.g. '%').string''
readonlyRead-only — disables interaction but keeps the visual.booleanfalse
disabledDisable interaction.booleanfalse
valueBound by [formField], or two-way via [(value)].number0
(touch)Emitted on blur so a bound field can mark itself touched.void—

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/knob's own element.

VariableDefaultDeclared on
--wr-knob-font-familyvar(--wr-font-family-base).wr-knob
--wr-knob-suffix-font-sizevar(--wr-text-sm).wr-knob__suffix
--wr-knob-suffix-font-weightvar(--wr-font-weight-medium).wr-knob__suffix
--wr-knob-suffix-margin-inline-startvar(--wr-space-xs).wr-knob__suffix
--wr-knob-text-font-sizevar(--wr-text-xl).wr-knob__text
--wr-knob-text-font-weightvar(--wr-font-weight-semibold).wr-knob__text

Dependencies

Built onForm

See also