React UI Components Documentation
The React Knob is a rotary knob with custom dials, markers and pointers. This guide adds the React Knob (jqxKnob) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-react-tsx/jqxknob 
In a React project (to start one, see Getting started with React), add the package:
npm install jqwidgets-scripts
import JqxKnob, { type IKnobProps } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxknob';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.tailwind-blue-dark.css';
jqx.base.css is required. The second file is a theme; pick one of the jqx.*.css files (material, fluent, light, dark and more) and pass its name to the theme prop.
The source of the live Default Functionality demo:
import { useRef, useCallback } from 'react';
import './App.css';
import JqxKnob, { type IKnobProps } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxknob';
import JqxNumberInput from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxnumberinput';
interface KnobChangeEvent {
args: { value: number };
}
const styles: IKnobProps['styles'] = {
fill: {
color: '#fefefe',
gradientStops: [
[0, 1],
[50, 0.9],
[100, 1]
],
gradientType: 'linear'
},
stroke: '#dfe3e9',
strokeWidth: 3
};
const marks: IKnobProps['marks'] = {
colorProgress: { border: '#00a4e1', color: '#00a4e1' },
colorRemaining: { border: 'grey', color: 'grey' },
majorInterval: 10,
majorSize: '9%',
minorInterval: 2,
offset: '71%',
size: '6%',
thickness: 3
};
const labels: IKnobProps['labels'] = { offset: '88%', step: 10, visible: true };
const pointer: IKnobProps['pointer'] = {
offset: '49%',
size: '59%',
style: { fill: '#00a4e1', stroke: 'grey' },
thickness: 20,
type: 'arrow'
};
const progressBar: IKnobProps['progressBar'] = {
background: { fill: 'grey', stroke: 'grey' },
offset: '60%',
size: '9%',
style: { fill: '#00a4e1', stroke: 'grey' }
};
function App() {
const myKnob = useRef<JqxKnob>(null);
const myNumberInput = useRef<JqxNumberInput>(null);
const onChange = useCallback((event: KnobChangeEvent) => {
if (myNumberInput.current) {
myNumberInput.current.val(event.args.value);
}
}, []);
const onValueChanged = useCallback(() => {
if (myNumberInput.current) {
const newValue = myNumberInput.current.val();
if (myKnob.current) {
myKnob.current.val(newValue);
}
}
}, []);
return (
<div>
<JqxKnob
ref={myKnob}
onChange={onChange}
value={60}
min={0}
max={100}
startAngle={120}
endAngle={420}
snapToStep={true}
rotation="clockwise"
styles={styles}
marks={marks}
labels={labels}
pointer={pointer}
progressBar={progressBar}
/>
<JqxNumberInput
theme="tailwind-blue-dark"
ref={myNumberInput}
onValueChanged={onValueChanged}
width={60}
height={40}
decimal={60}
min={0}
max={100}
textAlign="center"
decimalDigits={1}
inputMode="simple"
/>
</div>
);
}
export default App;Options are props. Keep objects such as the data adapter and the columns stable across renders with useMemo, so the component does not reload them.
Each event is a prop named on plus the event name with a capital first letter. For example, change: This event is triggered when the value is changed.
const handleChange = (event: any): void => {
console.log(event.args);
};
return <JqxKnob onChange={handleChange} />;
Call methods through a ref. For example, val: Sets or gets the value.
import { useRef } from 'react';
const myKnob = useRef<JqxKnob>(null);
const onClick = () => {
const value = myKnob.current!.val();
console.log(value);
};
return <JqxKnob ref={myKnob} />;
Every component also has setOptions({ … }) and getOptions('name'), to change or read options after the first render.