Knob

Knob is a form component to define number inputs with a dial.


import Knob from 'primevue/knob';

Knob is an input component and used with the standard v-model directive.

0

<Knob v-model="value" />

Boundaries are configured with the min and max values whose defaults are 0 and 100 respectively.

10

<Knob v-model="value" :min="-50" :max="50" />

Step factor is 1 by default and can be customized with step option.

40

<Knob v-model="value5" :step="10" />

Label is a string template that can be customized with the valueTemplate property having 60 as the placeholder .

60%

<Knob v-model="value" valueTemplate="{value}%" />

The border size is specified with the stroke property as a number in pixels.

40

<Knob v-model="value" :strokeWidth="5" />

Diameter of the knob is defined in pixels using the size property.

60

<Knob v-model="value" :size="200" />

valueColor defines the value color, rangeColor defines the range background and similarly textColor configures the color of the value text. In addition, strokeWidth is used to determine the width of the stroke of range and value sections.

50

<Knob v-model="value" valueColor="SlateGray" rangeColor="MediumTurquoise" />

Knob can be controlled with custom controls as well.

0

<Knob v-model="value" :size="150" readonly />
<div class="flex gap-2">
    <Button icon="pi pi-plus" @click="value++" :disabled="value >= 100" />
    <Button icon="pi pi-minus" @click="value--" :disabled="value <= 0" />
</div>

When readonly present, value cannot be edited.

50

<Knob v-model="value" readonly />

When disabled is present, a visual hint is applied to indicate that the Knob cannot be interacted with.

50

<Knob v-model="value" disabled />

Screen Reader

Knob element component uses slider role in addition to the aria-valuemin, aria-valuemax and aria-valuenow attributes. Value to describe the component can be defined using aria-labelledby and aria-label props.


<span id="label_number">Number</span>
<Knob aria-labelledby="label_number" />

<Knob aria-label="Number" />

Keyboard Support

KeyFunction
tabMoves focus to the slider.
left arrowdown arrowDecrements the value.
right arrowup arrowIncrements the value.
homeSet the minimum value.
endSet the maximum value.
page upIncrements the value by 10 steps.
page downDecrements the value by 10 steps.