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;
Modules§
- glyphs
- Stable codepoints for the icon glyphs bundled in the Elegance Symbols
font. All icons are sourced from Lucide and are
kept in sync via
scripts/update_lucide_glyphs.py. Use these inegui::RichTextwhen you want one of elegance’s icons in your own UI.
Structs§
- Accordion
- A grouped stack of collapsible items inside one bordered panel.
- Accordion
Item - A single row in an
Accordion. Configure with the builder methods and finish withAccordionItem::show. - Accordion
Ui - Handle passed to the
Accordion::showbody closure for declaring items. - 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.
- Collapsing
Section - A collapsible content section.
- Color
Picker - A click-to-open color picker bound to a
Color32. - Drawer
- A side-anchored slide-in overlay panel.
- File
Drop Response - The result of rendering a
FileDropZone. - File
Drop Zone - A click-and-drop file target.
- 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. - MenuBar
- A horizontal desktop-style menu bar with click-to-open dropdowns.
- Menu
BarUi - The handle passed to a
MenuBar::showclosure for declaring menu triggers. Each call toMenuBarUi::menupaints one trigger and its dropdown. - Menu
Item - A single selectable row inside a
Menu. - Modal
- A centered modal dialog.
- Multi
Terminal - Multi-pane terminal with per-pane broadcast toggles.
- Pair
Item - A single item rendered in either column of a
Pairingwidget. - 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.
- Popover
- A click-to-toggle popover anchored to a trigger
Response. - Progress
Bar - A horizontal determinate progress bar.
- Progress
Ring - A themed determinate circular progress indicator.
- Range
Slider - A horizontal numeric range slider with two thumbs.
- Segmented
Button - 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.
- Status
Pill - A capsule-shaped row of
(label, state)status items. - Steps
- A stepped progress indicator.
- SubMenu
Item - A menu row that opens a flyout submenu when hovered.
- 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.
- Terminal
Line - A single line in a
TerminalPane’s scrollback buffer. - Terminal
Pane - A single pane rendered by
MultiTerminal. - Text
Area - A styled multi-line text input.
- Text
Input - A styled single-line text input.
- Theme
- The full elegance theme — colours + typography + a handful of shapes.
- Theme
Switcher - A drop-in picker for the four built-in elegance themes.
- Toast
- A single enqueued notification.
- Toasts
- Renderer for the enqueued toast stack.
- Tooltip
- A hover-triggered tooltip attached to a
Response. - Typography
- Typography settings shared by all widgets.
Enums§
- Accent
- The six accent colours supported by elegance.
- Badge
Tone - Colour tones for a
Badge. - Built
InTheme - One of the four built-in elegance themes, as a typed enum.
- Button
Size - Size presets for buttons.
- Callout
Tone - Semantic tones for a
Callout. - Drawer
Side - Which edge of the viewport the drawer slides in from.
- Flash
Kind - Flash outcome. Controls the colour that tints the widget background.
- Indicator
State - The three visual states of an
Indicator. - Line
Kind - How a
TerminalLineis coloured when rendered. - LogKind
- How a single log row is styled and prefixed.
- Popover
Side - Which side of the trigger the popover opens on.
- Steps
Style - Visual style for a
Stepswidget. - Terminal
Event - Events emitted by
MultiTerminalthat the caller must react to. - Terminal
Status - Connection status for a
TerminalPane. - Tooltip
Side - Where the tooltip opens relative to its trigger.
Constants§
- FLASH_
DURATION - The duration of a flash animation, in seconds.
Traits§
- Response
Flash Ext - Extension trait that lets you trigger a flash directly on an
egui::Response. Import this trait (oruse 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 originatingResponsewent out of scope. - request_
repaint_ at_ rate - Request a repaint such that the next paint comes ~
1/hzseconds from now, independent of display refresh rate.