Knob is a form component to define number inputs with a dial.
import { Knob } from 'primereact/knob';
<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/knob/knob.min.js"></script>
Knob is used as a controlled input with value and onChange properties.
<Knob value={value} onChange={(e) => setValue(value)} />
Boundaries are configured with the min and max values whose defaults are 0 and 100 respectively.
<Knob value={value} min={0} max={100} onChange={(e) => setValue(value)} />
Step factor is 1 by default and can be customized with step option.
<Knob value={value} step={10} onChange={(e) => setValue(value)} />
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 value={value} valueColor={"SlateGray"} rangeColor={"MediumTurquoise"} onChange={(e) => setValue(value)} />
Default size of the Knob is 100 pixels for width and height, use the size property to customize it per your requirements.
<Knob value={value} size={200} onChange={(e) => setValue(value)} />
Any valid attribute is passed to the root element implicitly, extended properties are as follows;
Name | Type | Default | Description |
---|---|---|---|
id | string | null | Unique identifier of the element. |
value | number | null | Value of the component. |
size | number | 100 | Size of the component in pixels. |
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 | string | null | Background color of the range. |
textColor | string | 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 |
---|---|---|
onChange | value: New value | Callback to invoke when the value changes. |
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-knob | Container element. |
p-knob-range | Range element. |
p-knob-value | Value element. |
p-knob-text | Text element. |
This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.
None.
Built-in component themes created by the PrimeReact Theme Designer.
Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.
Beautifully crafted premium create-react-app application templates by the PrimeTek design team.