Knob

import Knob from 'frui/field/Knob';
Copy

Props

NameTypeRequiredNotes
defaultValuenumberNoInitial value for uncontrolled usage.
valuenumberNoControlled value of the knob.
onChangefunctionNoCallback when value changes.
namestringNoName for hidden input (for form submissions).
minnumberNoMinimum value. Default is 0.
maxnumberNoMaximum value. Default is 100.
stepnumberNoStep size when adjusting. Default is 1.
sizenumberNoSize of the knob in pixels.
strokenumberNoThickness of the knob stroke.
valueColorstringNoColor of the active stroke.
rangeColorstringNoColor of the background track.
textColorstringNoColor of the label text.
valueTemplatestringNoTemplate for displaying the value.

Basic

To use the knob, pass a value  and an onChange  callback.

35
<Knob defaultValue={35} />
Copy

Events

On Change

The onChange event is triggered when the value has changed. The following arguments are passed to the event handler:

NameTypeSample
eventEvent Objectsee: Change Event

Min/Max

To use the min/max, pass a value for min  and an max .

10
<Knob 
  value={min} 
  onChange={setMin} 
  min={10} 
  max={80} 
/>
Copy

Step

The size of the step is defined by the step  property.

40
<Knob 
  value={stepped} 
  onChange={setStepped} 
  step={10} 
/>
Copy

Size

To change the size of the knob component, pass a value for step 

45
<Knob 
  value={customSize} 
  onChange={setCustomSize} 
  size={150} 
/>
Copy

Stroke

To change thickness of stroke, pass a value for stroke .

60
<Knob 
  value={thickStroke} 
  onChange={setThickStroke} 
  stroke={15} 
/>
Copy

Color

To change color of the value, pass a value for valueColor . For the text color, pass a value to textColor .

55
<Knob 
  value={colorful} 
  onChange={setColorful} 
  valueColor="#e91e63" 
  textColor="#e91e63" 
/>
Copy

Track

To change color for the range, pass a value for rangeColor . For the value, pass a value for valueColor .

35
<Knob 
  value={tracked} 
  onChange={setTracked} 
  rangeColor="#ccc" 
  valueColor="#4caf50" 
/>
Copy

Value

To change the label, pass a value for valueTemplate 

35%
<Knob 
  value={value} 
  onChange={setValue} 
  valueTemplate="{}%" 
  textColor="#333" 
/>
Copy

Custom Styles

You can add your own custom class to knob or use the  frui-field-knob CSS class.