Skip to main content

Crate elegance

Crate elegance 

Source
Expand description

Elegance — opinionated, beautiful widgets for egui.

Elegance is a small companion crate to egui that provides a cohesive design system inspired by modern web UIs: chunky rounded buttons in a handful of accent colors, crisp inputs with a focus ring, pill-shaped status indicators, cards, tabs, segmented buttons, and a matching colour palette. Four palettes ship built-in — two dark (Theme::slate and Theme::charcoal) and two light (Theme::frost and Theme::paper) — paired so you can toggle without a layout shift.

§Getting started

use eframe::egui;
use elegance::{Theme, Button, Card, Accent};

fn main() -> eframe::Result<()> {
    eframe::run_ui_native(
        "elegance demo",
        eframe::NativeOptions::default(),
        |ui, _| {
            Theme::slate().install(ui.ctx());
            egui::CentralPanel::default().show_inside(ui, |ui| {
                Card::new().heading("Hello").show(ui, |ui| {
                    if ui.add(Button::new("Click me").accent(Accent::Blue))
                        .clicked()
                    {
                        println!("clicked!");
                    }
                });
            });
        },
    )
}

§Design

All visuals are driven by a Theme value. Calling Theme::install once at startup configures egui::Style so that built-in widgets (labels, sliders, etc.) inherit the elegance look, and it stores the theme in ctx memory so elegance widgets can pick it up automatically.

Re-exports§

pub use egui;

Structs§

Badge
A compact rounded status badge.
Button
A coloured, rounded button.
Callout
A full-width inline banner in the elegance style.
Card
A styled card surface.
Checkbox
A styled checkbox.
CollapsingSection
A collapsible content section.
Indicator
A small status light.
LogBar
An expandable log bar anchored to the bottom of the viewport.
LogEntry
A single log row.
Menu
A click-to-open popup menu anchored below a trigger Response.
MenuItem
A single selectable row inside a Menu.
Modal
A centered modal dialog.
MultiTerminal
Multi-pane terminal with per-pane broadcast toggles.
PairItem
A single item rendered in either column of a Pairing widget.
Pairing
A widget that lets users connect items in two lists with 1:1 pairings, drawn as bezier curves between ports on each node.
Palette
All the colours used by the design system.
ProgressBar
A horizontal determinate progress bar.
SegmentedButton
A toggle button with a built-in LED dot.
Select
A styled drop-down select.
Slider
A horizontal numeric slider.
Spinner
A themed loading spinner.
StatusPill
A capsule-shaped row of (label, state) status items.
Switch
A sliding on/off switch bound to a &mut bool.
TabBar
A horizontal tab bar. The active tab is indicated by a sky-coloured underline and an inactive tab lights up on hover.
TerminalLine
A single line in a TerminalPane’s scrollback buffer.
TerminalPane
A single pane rendered by MultiTerminal.
TextArea
A styled multi-line text input.
TextInput
A styled single-line text input.
Theme
The full elegance theme — colours + typography + a handful of shapes.
ThemeSwitcher
A drop-in picker for the four built-in elegance themes.
Toast
A single enqueued notification.
Toasts
Renderer for the enqueued toast stack.
Typography
Typography settings shared by all widgets.

Enums§

Accent
The six accent colours supported by elegance.
BadgeTone
Colour tones for a Badge.
BuiltInTheme
One of the four built-in elegance themes, as a typed enum.
ButtonSize
Size presets for buttons.
CalloutTone
Semantic tones for a Callout.
FlashKind
Flash outcome. Controls the colour that tints the widget background.
IndicatorState
The three visual states of an Indicator.
LineKind
How a TerminalLine is coloured when rendered.
LogKind
How a single log row is styled and prefixed.
TerminalEvent
Events emitted by MultiTerminal that the caller must react to.
TerminalStatus
Connection status for a TerminalPane.

Constants§

FLASH_DURATION
The duration of a flash animation, in seconds.

Traits§

ResponseFlashExt
Extension trait that lets you trigger a flash directly on an egui::Response. Import this trait (or use elegance::*) to bring the methods into scope.

Functions§

flash_error
Begin an error flash on the widget with the given id. Async counterpart to ResponseFlashExt::flash_error.
flash_success
Begin a success flash on the widget with the given id. Use when you only have the widget id and a Context, e.g. when completing an async callback that returned after the originating Response went out of scope.
request_repaint_at_rate
Request a repaint such that the next paint comes ~1/hz seconds from now, independent of display refresh rate.