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, Window};
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//! [`Window`](crate::widgets::Window)
44//! - [`components`] — feature-gated composites (`secure-types`, `qr-image`, `qr-scanner`)
45//! - [`editor`] — live [`ThemeEditor`](crate::editor::ThemeEditor)
46//! - [`utils`] — [`theme_switcher`](crate::utils::theme_switcher), HSLA helpers
47//! - [`overlay`] — dimming overlay for stacked windows
48//! - [`visuals`] — per-widget chrome (`ButtonVisuals`, `TextEditVisuals`, …)
49//!
50//! # Features
51//!
52//! | Feature | What it enables |
53//! |---------|-----------------|
54//! | `serde` | `Serialize` / `Deserialize` on theme types; `egui/serde` |
55//! | `lucide` | [`egui-lucide`](https://docs.rs/egui-lucide) SVG icons. Also enabled by `secure-types` and `qr-scanner`. |
56//! | `secure-types` | [`SecureString`](https://docs.rs/secure-types) buffers, credentials form, virtual keyboard |
57//! | `qr-image` | Encode a string as a QR [`Image`](egui::Image) |
58//! | `qr-scanner` | Linux screen-capture QR scanner (`xcap` + `rqrr-zeroize`) |
59//! | `elegance` | Push the current palette into [`egui-elegance`](https://docs.rs/egui-elegance) |
60//! | `full` | All of the above |
61//!
62//! Run the showcase with:
63//!
64//! ```text
65//! cargo run --example demo --features full
66//! ```
67//!
68//! See the crate README for system packages required by `qr-scanner`.
69//!
70//! [`ComboBox`](crate::widgets::ComboBox) and [`Window`](crate::widgets::Window) have
71//! the same names as [`egui::ComboBox`] and [`egui::Window`]. Import this crate's
72//! widgets after `use egui::*`, or alias one of them.
73
74pub mod components;
75pub mod editor;
76pub mod overlay;
77pub mod theme;
78pub mod themes;
79pub mod utils;
80pub mod visuals;
81pub mod widgets;
82
83pub use overlay::OverlayManager;
84pub use theme::{Theme, ThemeKind};
85pub use widgets::{Button, ComboBox, Frame, Label, Modal, MultiLabel, Window};
86
87#[cfg(feature = "secure-types")]
88pub use widgets::SecureTextEdit;
89
90#[cfg(any(feature = "secure-types", feature = "lucide"))]
91pub use egui_lucide;
92
93#[cfg(all(feature = "qr-scanner", target_os = "linux"))]
94pub use components::QRScanner;
95
96#[cfg(feature = "secure-types")]
97pub use components::{CredentialsForm, SecureInputField, VirtualKeyboard};
98
99#[cfg(feature = "qr-image")]
100pub use components::QrImage;