Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Knob

A circular input for adjusting a normalized value.

When To Use It

Use Knob for audio and media style controls (gain, pan, filter cutoff) where a compact circular control is preferred.

Constructing a Knob

Knob::new binds to a normalized value in the range 0.0..=1.0:

let value = Signal::new(0.5f32);

Knob::new(cx, 0.5, value, false)
	.on_change(|cx, normalized| cx.emit(AppEvent::SetNormalized(normalized)));

Custom content:

Knob::custom(cx, 0.5, value, |cx, value| {
	ZStack::new(cx, |cx| {
		ArcTrack::new(
			cx,
			false,
			Percentage(100.0),
			Percentage(15.0),
			-240.0,
			60.0,
			KnobMode::Continuous,
		)
		.value(value)
		.class("knob-track");
	})
})
.on_change(|cx, normalized| cx.emit(AppEvent::SetNormalized(normalized)));

Knob Modifiers

ModifierTypeDescriptionDefault
on_changeFn(&mut EventContext, f32)Called with normalized value when control changes.-

Components and Styling

SelectorDescription
knobRoot element.
knob .knob-trackArc track element.
knob .knob-headRotating indicator container.
knob .knob-tickTick/marker on the knob head.
arctrackArc track view element (used by ArcTrack).
ticksTick marks container view element (used by TickKnob).
tickknobRotating knob head view element (used by TickKnob).

Accessibility

Knob exposes slider semantics (Role::Slider) with min/max numeric range.

Keyboard interaction:

KeyAction
ArrowUp / ArrowRightIncrement normalized value
ArrowDown / ArrowLeftDecrement normalized value

Pointer interaction:

  • Drag vertically to change value.
  • Mouse wheel adjusts value.
  • Double click resets to normalized_default.