Knob API

API documentation for Knob component

Knob#

Props#

Defines valid properties in Knob component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: KnobInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: KnobInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<KnobPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: KnobInstance) => ReactNode)
null
The children to render.
tabindexnumber
0
Index of the element in tabbing order.
invalidboolean
false
When present, it specifies that the component should have invalid state style.
ariaLabelledbystring
null
Establishes relationships between the component and label(s) where its value should be one or more element IDs.
ariaLabelstring
null
Used to define a string that labels the element.
onValueChange(event: KnobChangeEvent) => void
null
Callback fired when the knob's value changes.
defaultValuenumber
undefined
Value of the knob.
valuenumber
undefined
The default value of the knob.
sizenumber
100
Size of the component in pixels.
stepnumber
1
Step factor to increment/decrement the value.
minnumber
0
Mininum boundary value.
maxnumber
100
Maximum boundary value.
readOnlyboolean
false
When present, it specifies that the component value cannot be edited.
disabledboolean
false
When present, it specifies that the component should be disabled.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Defines valid state in Knob component.

nametypedefaultdescription
valuenumber
null
The value of the knob.

Exposes#

Defines the methods and properties exposed by Knob component.

nametypedefaultdescription
stateuseKnobState
null
The state of the useKnob.
rangePathstring
null
The path string for the range arc of the knob.
valuePathstring
null
The path string for the value arc of the knob.
onClick(event: MouseEvent) => void
null
Callback fired when the knob is clicked.
onMouseDown(event: MouseEvent) => void
null
Callback fired when mouse down occurs on the knob.
onMouseUp() => void
null
Callback fired when mouse up occurs.
onTouchStart() => void
null
Callback fired when touch starts on the knob.
onTouchEnd() => void
null
Callback fired when touch ends.
onMouseMove(event: MouseEvent) => void
null
Callback fired when mouse moves while dragging the knob.
onTouchMove(event: TouchEvent) => void
null
Callback fired when touch moves while dragging the knob.
onKeyDown(event: KeyboardEvent) => void
null
Callback fired when a key is pressed while the knob is focused.

Events#

Event fired when the knob's value changes.

nametypedescription
valuenumberThe value of the knob.

Interfaces#

Defines passthrough(pt) options of Knob component.

nametypedefaultdescription
rootKnobPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.
svgKnobPassThroughType<HTMLAttributes<SVGSVGElement>>
null
Used to pass attributes to the svg's DOM element.
rangeKnobPassThroughType<HTMLAttributes<SVGPathElement>>
null
Used to pass attributes to the range's DOM element.
valueKnobPassThroughType<HTMLAttributes<SVGPathElement>>
null
Used to pass attributes to the value's DOM element.
textKnobPassThroughType<HTMLAttributes<SVGTextElement>>
null
Used to pass attributes to the text's DOM element.

Types#

Instance of Knob component.

values
ComponentInstance<KnobProps, KnobState, KnobExposes>

KnobRange#

Props#

Defines valid properties in KnobRange component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: KnobRangeInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: KnobRangeInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<KnobRangePassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: KnobRangeInstance) => ReactNode)
null
The children to render.
strokeWidthnumber
14
Width of the knob stroke.
colorstring
$dt('knob.range.background')
Background color of the range.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

Exposes#

Defines the methods and properties exposed by KnobRange component.

nametypedefaultdescription
knobKnobInstance
null
The Knob component instance.

Interfaces#

Defines passthrough(pt) options of KnobRange component.

nametypedefaultdescription
rootKnobRangePassThroughType<HTMLAttributes<SVGPathElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of KnobRange component.

values
ComponentInstance<KnobRangeProps, KnobRangeState, KnobRangeExposes>

KnobValue#

Props#

Defines valid properties in KnobValue component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: KnobValueInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: KnobValueInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<KnobValuePassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: KnobValueInstance) => ReactNode)
null
The children to render.
strokeWidthnumber
14
Width of the knob stroke.
colorstring
$dt('knob.value.background')
Background color of the value.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

Exposes#

Defines the methods and properties exposed by KnobValue component.

nametypedefaultdescription
knobKnobInstance
null
The Knob component instance.

Interfaces#

Defines passthrough(pt) options of KnobValue component.

nametypedefaultdescription
rootKnobValuePassThroughType<HTMLAttributes<SVGPathElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of KnobValue component.

values
ComponentInstance<KnobValueProps, KnobValueState, KnobValueExposes>

KnobText#

Props#

Defines valid properties in KnobText component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: KnobTextInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: KnobTextInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<KnobTextPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: KnobTextInstance) => ReactNode)
null
The children to render.
strokeWidthnumber
14
Width of the knob stroke.
colorstring
$dt('knob.text.color')
Color of the text.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

Exposes#

Defines the methods and properties exposed by KnobText component.

nametypedefaultdescription
knobKnobInstance
null
The Knob component instance.

Interfaces#

Defines passthrough(pt) options of KnobText component.

nametypedefaultdescription
rootKnobTextPassThroughType<HTMLAttributes<SVGTextElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of KnobText component.

values
ComponentInstance<KnobTextProps, KnobTextState, KnobTextExposes>

useKnob#

Props#

Defines valid properties in useKnob.

nametypedefaultdescription
defaultValuenumber
undefined
Value of the knob.
valuenumber
undefined
The default value of the knob.
sizenumber
100
Size of the component in pixels.
stepnumber
1
Step factor to increment/decrement the value.
minnumber
0
Mininum boundary value.
maxnumber
100
Maximum boundary value.
readOnlyboolean
false
When present, it specifies that the component value cannot be edited.
disabledboolean
false
When present, it specifies that the component should be disabled.
onValueChange(event: useKnobChangeEvent) => void
null
Callback fired when the knob's value changes.

State#

Defines valid state in useKnob.

nametypedefaultdescription
valuenumber
null
The value of the knob.

Exposes#

Defines the methods and properties exposed by useKnob.

nametypedefaultdescription
stateuseKnobState
null
The state of the useKnob.
rangePathstring
null
The path string for the range arc of the knob.
valuePathstring
null
The path string for the value arc of the knob.
onClick(event: MouseEvent) => void
null
Callback fired when the knob is clicked.
onMouseDown(event: MouseEvent) => void
null
Callback fired when mouse down occurs on the knob.
onMouseUp() => void
null
Callback fired when mouse up occurs.
onTouchStart() => void
null
Callback fired when touch starts on the knob.
onTouchEnd() => void
null
Callback fired when touch ends.
onMouseMove(event: MouseEvent) => void
null
Callback fired when mouse moves while dragging the knob.
onTouchMove(event: TouchEvent) => void
null
Callback fired when touch moves while dragging the knob.
onKeyDown(event: KeyboardEvent) => void
null
Callback fired when a key is pressed while the knob is focused.

Events#

Event fired when the knob's value changes.

nametypedescription
valuenumberThe value of the knob.

Types#

Instance of useKnob headless.

values
HeadlessInstance<useKnobProps, useKnobState, useKnobExposes>