#widgets #egui #ui #range #knob

egui_knob

A simple knob widget for egui

7 releases

new 0.1.9 Feb 4, 2025
0.1.8 Feb 3, 2025

#228 in GUI

Download history 488/week @ 2025-01-29

488 downloads per month

MIT license

40KB
198 lines

egui_knob

Crates.io Version

Simple knob widget for egui.

Knob Widget Screenshot

Features

  • Adjustable size, font size, and stroke width.
  • Customizable colors for the knob, indicator and text.
  • Label positions (Top, Bottom, Left, Right).
  • Label formating.
  • Two styles: Wiper and Dot.

Installation

To use the Knob widget in your project, add the following to your Cargo.toml:

[dependencies]
egui = "0.30"
egui_knob = "*"

Usage example

use egui::{Color32, Context};
use egui_knob::Knob;

// ..

let mut value: f32 = 0.5;
let knob = Knob::new(&mut value, 0.0, 1.0, KnobStyle::Wiper)
    .with_size(50.0)
    .with_font_size(14.0)
    .with_stroke_width(3.0)
    .with_colors(Color32::GRAY, Color32::WHITE, Color32::WHITE)
    .with_label("Volume", LabelPosition::Top);

egui::CentralPanel::default().show(ctx, |ui| {
    ui.add(knob);
});

Dependencies

~4.5–9MB
~87K SLoC