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/Windows QR scanner).
7//!
8//! # Quick start
9//!
10//! ```no_run
11//! use egui::{Context, Ui};
12//! use egui_elements::{Theme, ThemeKind};
13//! use egui_elements::Button;
14//!
15//! fn ui(ctx: &Context, ui: &mut Ui) {
16//! let mut theme = Theme::new(ThemeKind::TokyoNight);
17//! theme.install(ctx);
18//!
19//! if ui.add(Button::new("Save")).clicked() {
20//! // …
21//! }
22//! }
23//! ```
24//!
25//! Custom widgets pick up [`visuals`] from the installed
26//! [`Theme`](crate::theme::Theme). You can still override a single widget
27//! with `.visuals(...)`.
28//!
29//! # Modules
30//!
31//! - [`theme`] / [`themes`] — palettes, [`ThemeKind`](crate::theme::ThemeKind), install
32//! - [`widgets`] — [`Button`](crate::widgets::Button), [`Label`](crate::widgets::Label)
33//! (including [`Label::sections`](crate::widgets::Label::sections) for mixed styles),
34//! [`ComboBox`](crate::widgets::ComboBox), [`Modal`](crate::widgets::Modal),
35//! [`SecureTextEdit`](crate::widgets::SecureTextEdit), [`MultiLabel`](crate::widgets::MultiLabel),
36//! [`Window`](crate::widgets::Window)
37//! - [`components`] — feature-gated composites (`secure-types`, `qr-image`, `qr-scanner`)
38//! - [`editor`] — live [`ThemeEditor`](crate::editor::ThemeEditor)
39//! - [`utils`] — [`theme_switcher`](crate::utils::theme_switcher), HSLA helpers
40//! - [`overlay`] — dimming overlay for stacked windows
41//! - [`visuals`] — per-widget chrome (`ButtonVisuals`, `TextEditVisuals`, …)
42//!
43//! # Features
44//!
45//! | Feature | What it enables |
46//! |---------|-----------------|
47//! | `serde` | `Serialize` / `Deserialize` on theme types; `egui/serde` |
48//! | `lucide` | [`egui-lucide`](https://docs.rs/egui-lucide) SVG icons. Also enabled by `secure-types` and `qr-scanner`. |
49//! | `secure-types` | [`SecureString`](https://docs.rs/secure-types) buffers, credentials form, virtual keyboard |
50//! | `qr-image` | Encode a string as a QR [`Image`](egui::Image) |
51//! | `qr-scanner` | Linux/Windows screen-capture QR scanner (`xcap` + `rqrr-zeroize`) |
52//! | `elegance` | Push the current palette into [`egui-elegance`](https://docs.rs/egui-elegance) |
53//! | `full` | All of the above |
54//!
55//! Run the showcase with:
56//!
57//! ```text
58//! cargo run --example demo --features full
59//! ```
60//!
61//! See the crate README for system packages required by `qr-scanner`.
62//!
63//! [`ComboBox`](crate::widgets::ComboBox) and [`Window`](crate::widgets::Window) have
64//! the same names as [`egui::ComboBox`] and [`egui::Window`]. Import this crate's
65//! widgets after `use egui::*`, or alias one of them.
66
67pub mod components;
68pub mod editor;
69pub mod theme;
70pub mod themes;
71pub mod utils;
72pub mod visuals;
73pub mod widgets;
74
75pub use theme::{Theme, ThemeKind};
76pub use widgets::{Badge, BadgeCorner, Button, ComboBox, Frame, Label, Modal, MultiLabel, Window};
77
78#[cfg(feature = "secure-types")]
79pub use widgets::SecureTextEdit;
80
81#[cfg(any(feature = "secure-types", feature = "lucide"))]
82pub use egui_lucide;
83
84#[cfg(all(
85 feature = "qr-scanner",
86 any(target_os = "linux", target_os = "windows")
87))]
88pub use components::QRScanner;
89
90#[cfg(feature = "secure-types")]
91pub use components::{CredentialsForm, InputField, SecureInputField, VirtualKeyboard};
92
93#[cfg(feature = "qr-image")]
94pub use components::QrImage;