| Crates.io | egui_knob |
| lib.rs | egui_knob |
| version | 0.3.10 |
| created_at | 2025-02-03 09:58:43.774876+00 |
| updated_at | 2026-01-23 08:01:43.34103+00 |
| description | A simple knob widget for egui |
| homepage | https://github.com/obsqrbtz/egui_knob |
| repository | https://github.com/obsqrbtz/egui_knob |
| max_upload_size | |
| id | 1540272 |
| size | 251,947 |
A simple, customizable knob widget for egui.

To use the Knob widget in your project, add the following to your Cargo.toml:
[dependencies]
egui = "0.33"
eframe = "0.33"
egui_knob = "0.3.10"
use egui_knob::{Knob, KnobStyle, LabelPosition};
use eframe::egui;
struct KnobApp {
value: f32,
}
impl Default for KnobApp {
fn default() -> Self {
Self { value: 0.5 }
}
}
impl eframe::App for KnobApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
let knob = Knob::new(&mut self.value, 0.0, 1.0, KnobStyle::Wiper)
.with_size(50.0)
.with_font_size(14.0)
.with_colors(egui::Color32::GRAY, egui::Color32::WHITE, egui::Color32::WHITE)
.with_stroke_width(3.0)
.with_label("Volume", LabelPosition::Top);
ui.add(knob);
});
}
}
fn main() -> eframe::Result<()> {
eframe::run_native(
"Knob Example",
eframe::NativeOptions::default(),
Box::new(|_cc| Ok(Box::new(KnobApp::default()))),
)
}
// 270° sweep starting from the left (9 o'clock position)
Knob::new(&mut value, 0.0, 100.0, KnobStyle::Wiper)
.with_sweep_range(0.25, 0.75)
.with_label("Gain", LabelPosition::Bottom);
// 2.5 full rotations
Knob::new(&mut value, 0.0, 1.0, KnobStyle::Dot)
.with_sweep_range(0.0, 2.5);
// Snap to 0.1 increments
Knob::new(&mut value, 0.0, 1.0, KnobStyle::Wiper)
.with_step(Some(0.1))
.with_label_format(|v| format!("{:.1}", v));
// Display as percentage
Knob::new(&mut value, 0.0, 1.0, KnobStyle::Wiper)
.with_label_format(|v| format!("{:.0}%", v * 100.0));
// Enable logarithmic scaling
Knob::new(&mut value, 0.0, 1.0, KnobStyle::Wiper)
.with_logarithmic_scaling();
cargo run --example example_knob
Demo app is available at examples/example_knob.rs.
Contributions are welcome. Feel free to open an issue or submit a PR.