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.
+
+
+<Knob v-model="value" />
+
+
+
+
+data() {
+ return {
+ value: 0
+ }
+}
+
+
+
+ Boundaries are configured with the min and max values whose defaults are 0 and 100 respectively.
+
+
+<Knob v-model="value" :min="-50" :max="10" />
+
+
+
+ Step factor is 1 by default and can be customized with step option.
+
+
+<Knob v-model="value" :step="10" />
+
+
+
+ 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.
+
+
+<Knob v-model="value" valueColor="SlateGray" rangeColor="MediumTurquoise" />
+
+
+
+ Default size of the Knob is 100 pixels for width and height, use the size property to customize it per your requirements.
+
+
+<Knob v-model="value" :size="200" />
+
+
+
+ Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.
+Name | +Type | +Default | +Description | +
---|---|---|---|
modelValue | +number | +null | +Value of the component. | +
disabled | +boolean | +false | +When present, it specifies that the component should be disabled. | +
readonly | +boolean | +false | +When present, it specifies that the component value cannot be edited. | +
step | +number | +null | +Step factor to increment/decrement the value. | +
min | +number | +0 | +Mininum boundary value. | +
max | +number | +100 | +Maximum boundary value. | +
valueColor | +string | +null | +Background of the value. | +
rangeColor | +number | +null | +Background color of the range. | +
textColor | +number | +null | +Color of the value text. | +
strokeWidth | +number | +14 | +Width of the knob stroke. | +
showValue | +boolean | +true | +Whether the show the value inside the knob. | +
valueTemplate | +string | +{value} | +Template string of the value. | +
Name | +Parameters | +Description | +
---|---|---|
change | +value: New value | +Callback to invoke when the value changes. | +
Following is the list of structural style classes, for theming classes visit
Name | +Element | +
---|---|
p-knob | +Container element. | +
p-knob-text | +Text element. | +
p-knob-value | +Value element. | +
p-knob-text | +Text element. | +
None.
+
+
+<div class="p-grid p-formgrid p-text-center">
+ <div class="p-field p-col-12 p-md-4">
+ <h5>Basic</h5>
+ <Knob v-model="value1" />
+ </div>
+ <div class="p-field p-col-12 p-md-4">
+ <h5>Readonly</h5>
+ <Knob v-model="value2" readonly />
+ </div>
+ <div class="p-field p-col-12 p-md-4">
+ <h5>Disabled</h5>
+ <Knob v-model="value3" disabled />
+ </div>
+ <div class="p-field p-col-12 p-md-4">
+ <h5 class="p-mt-3">Min/Max</h5>
+ <Knob v-model="value4" :min="-50" :max="50" />
+ </div>
+ <div class="p-field p-col-12 p-md-4">
+ <h5 class="p-mt-3">Step</h5>
+ <Knob v-model="value5" :step="10" />
+ </div>
+ <div class="p-field p-col-12 p-md-4">
+ <h5 class="p-mt-3">Template</h5>
+ <Knob v-model="value6" valueTemplate="{value}%" />
+ </div>
+ <div class="p-field p-col-12 p-md-4">
+ <h5 class="p-mt-3">Stroke</h5>
+ <Knob v-model="value7" :strokeWidth="5" />
+ </div>
+ <div class="p-field p-col-12 p-md-4">
+ <h5 class="p-mt-3">Size</h5>
+ <Knob v-model="value8" :size="200"/>
+ </div>
+ <div class="p-field p-col-12 p-md-4">
+ <h5 class="p-mt-3">Color</h5>
+ <Knob v-model="value9" valueColor="SlateGray" rangeColor="MediumTurquoise" />
+ </div>
+</div>
+
+
+
+
+
+export default {
+ data() {
+ return {
+ value1: 0,
+ value2: 50,
+ value3: 75,
+ value4: 10,
+ value5: 40,
+ value6: 60,
+ value7: 40,
+ value8: 60,
+ value9: 50,
+ }
+ }
+}
+
+
+