Skip to main content

egui_elements/
lib.rs

1//! Widgets, themes, and optional components for [egui](https://github.com/emilk/egui).
2//!
3//! This crate is **not** a drop-in replacement for stock egui widgets. It
4//! ships a themed widget set, a palette of built-in looks, a live theme
5//! editor, and a few higher-level components (credentials form, QR image,
6//! Linux QR scanner).
7//!
8//! There are no crate-root re-exports. Import from the modules:
9//!
10//! ```
11//! use egui_elements::theme::{Theme, ThemeKind};
12//! use egui_elements::widgets::{Button, ComboBox, Label, Modal, SecureTextEdit};
13//! use egui_elements::utils::theme_switcher;
14//! ```
15//!
16//! # Quick start
17//!
18//! ```no_run
19//! use egui::{Context, Ui};
20//! use egui_elements::theme::{Theme, ThemeKind};
21//! use egui_elements::widgets::Button;
22//!
23//! fn ui(ctx: &Context, ui: &mut Ui) {
24//!     let mut theme = Theme::new(ThemeKind::TokyoNight);
25//!     theme.install(ctx);
26//!
27//!     if ui.add(Button::new("Save")).clicked() {
28//!         // …
29//!     }
30//! }
31//! ```
32//!
33//! Custom widgets pick up [`visuals`] from the installed
34//! [`Theme`](crate::theme::Theme). You can still override a single widget
35//! with `.visuals(...)`.
36//!
37//! # Modules
38//!
39//! - [`theme`] / [`themes`] — palettes, [`ThemeKind`](crate::theme::ThemeKind), install
40//! - [`widgets`] — [`Button`](crate::widgets::Button), [`Label`](crate::widgets::Label),
41//!   [`ComboBox`](crate::widgets::ComboBox), [`Modal`](crate::widgets::Modal),
42//!   [`SecureTextEdit`](crate::widgets::SecureTextEdit), [`MultiLabel`](crate::widgets::MultiLabel)
43//! - [`components`] — feature-gated composites (`secure-types`, `qr-image`, `qr-scanner`)
44//! - [`editor`] — live [`ThemeEditor`](crate::editor::ThemeEditor)
45//! - [`utils`] — [`theme_switcher`](crate::utils::theme_switcher), HSLA helpers
46//! - [`overlay`] — dimming overlay for stacked windows
47//! - [`visuals`] — per-widget chrome (`ButtonVisuals`, `TextEditVisuals`, …)
48//!
49//! # Features
50//!
51//! | Feature | What it enables |
52//! |---------|-----------------|
53//! | `serde` | `Serialize` / `Deserialize` on theme types; `egui/serde` |
54//! | `secure-types` | [`SecureString`](https://docs.rs/secure-types) buffers, credentials form, virtual keyboard |
55//! | `qr-image` | Encode a string as a QR [`Image`](egui::Image) |
56//! | `qr-scanner` | Linux screen-capture QR scanner (`xcap` + `rqrr-zeroize`) |
57//! | `elegance` | Push the current palette into [`egui-elegance`](https://docs.rs/egui-elegance) |
58//! | `full` | All of the above |
59//!
60//! Run the showcase with:
61//!
62//! ```text
63//! cargo run --example demo --features full
64//! ```
65//!
66//! See the crate README for system packages required by `qr-scanner`.
67//!
68//! [`ComboBox`](crate::widgets::ComboBox) has the same name as
69//! [`egui::ComboBox`]. Import this crate's widgets after `use egui::*`, or
70//! alias one of them.
71
72pub mod components;
73pub mod editor;
74pub mod overlay;
75pub mod theme;
76pub mod themes;
77pub mod utils;
78pub mod visuals;
79pub mod widgets;