Guides
Custom controls
Draw a control of your own on top of Soundor interaction hooks.
Use a headless hook when the styled components do not fit your design. The hook owns the interaction; you own the pixels.
- Call the hook with the props the matching component takes: a
parameter, orvalueandonChange. - Spread
handlersonto a focusable SoundorView. They supply pointer, wheel and keyboard input, plus the accessibility role and value. - Draw from the state.
normalizedruns0–1across the range whatever the parameter's mapping,focusVisibleis true only for keyboard focus, andhoveredandpressedfollow the pointer.
import { useKnob } from '@soundor/components/headless';
import { View } from '@soundor/react';
function CustomKnob({
value,
onChange,
}: {
value: number;
onChange: (v: number) => void;
}) {
const knob = useKnob({ label: 'Mix', value, onChange, defaultValue: 0.5 });
return (
<View {...knob.handlers} style={{ width: 64, height: 64 }}>
<Dial position={knob.normalized} focused={knob.focusVisible} />
</View>
);
}Importing from @soundor/components/headless loads neither the theme nor the fonts. Hooks are available for each control: useKnob, useSlider, useFader, useValueField, useXYPad and useResizeGrip. For a custom chart, see the chart helpers.