ImageKnob
A continuous control that rotates an image based on a normalized value, perfect for custom knob designs using bitmap graphics.
ImageKnob is a continuous control that rotates an image based on a normalized value. It shares the same layout, parameter model, interaction, and accessibility as other controls (vector, raster, and control primitives); see the Raster introduction.
The image rotation is determined by the normalized value (0-1 maps to rotation based on openness and rotation offset).
Note:
No Theming Support: This component does NOT support themable props (color, roundness, thickness) as visuals are entirely determined by the image content.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
value | number | — | Yes | Current value of the control |
onChange | (event: AudioControlEvent<number>) => void | — | No | Handler for value changes |
min | number | — | No | Minimum value (ad-hoc mode) |
max | number | — | No | Maximum value (ad-hoc mode) |
step | number | — | No | Step size for value adjustments |
bipolar | boolean | false | No | Whether the component should operate in bipolar mode (centered at zero) |
label | string | — | No | Label displayed below the component |
frameWidth | number | — | Yes | Width of the viewBox (determines viewBox width) |
frameHeight | number | — | Yes | Height of the viewBox (determines viewBox height) |
imageHref | string | — | Yes | URL to the image to rotate |
rotation | number | 0 | No | Optional rotation angle offset in degrees |
openness | number | 90 | No | Openness of the arc in degrees (value between 0-360º; 0º closed, 90º 3/4 open, 180º half-circle) |
valueAsLabel | "labelOnly" | "valueOnly" | "interactive" | labelOnly | No | Controls how the label and value are displayed |
adaptiveSize | boolean | false | No | Whether the component stretches to fill its container |
size | "xsmall" | "small" | "normal" | "large" | "xlarge" | normal | No | Size of the component |
parameter | ContinuousParameter | — | No | Audio Parameter definition (Model). If provided, overrides min/max/step/label/bipolar from ad-hoc props |
valueFormatter | (value: number, parameterDef: AudioParameter) => string | undefined | — | No | Custom renderer for the value display |
interactionMode | "drag" | "wheel" | "both" | both | No | Interaction mode |
interactionDirection | "vertical" | "horizontal" | "circular" | "both" | — | No | Direction of interaction |
interactionSensitivity | number | — | No | Sensitivity multiplier for interactions (default varies by control type) |
Basic Usage
ImageKnob requires an image URL and frame dimensions:
Rotation Configuration
Openness
Control the rotation range using the openness prop:
Rotation Offset
Apply a rotation offset to align the image:
Parameter Model
Use a parameter model for integration with audio parameter systems. The following example uses ad-hoc props; with the full library you would use createContinuousParameter and the parameter prop:
Adaptive Sizing
The ImageKnob component supports both fixed sizes and adaptive sizing. By default, the size of the component is driven by the Size System and their size attribute:
Adaptive sizing allows the component to adapt to the size of its parent container, adjusting its dimensions intelligently without causing distortion (scaleToFit display mode). The fill display mode makes the component fill the entire container, potentially distorting it.
Interaction Modes
Control how users interact with the knob:
Common Use Cases
Volume Knob
Tone Knob
Direction Indicator
Image Requirements
- Format: Any image format supported by browsers (PNG, JPG, SVG, etc.)
- Dimensions: The
frameWidthandframeHeightprops determine the viewBox dimensions - Aspect Ratio: The image will be scaled to fit the viewBox while preserving aspect ratio
- Rotation: The image rotates around its center point based on the normalized value
Rotation Calculation
The rotation angle is calculated as:
- Normalized value (0-1) maps to rotation range based on
openness rotationoffset is added to align the image- For bipolar mode, the rotation is centered around the midpoint
Next Steps
- Explore ImageRotarySwitch for discrete rotary controls
- Learn about ImageSwitch for boolean switches
- Check out the playground for interactive examples