Skip to main content

lumen_dioxus/
lib.rs

1//! Lumen UI components for [Dioxus](https://dioxuslabs.com).
2//!
3//! The components render the same classes and attributes as `@santi020k/lumen-react`, so they
4//! share Lumen's stylesheet. They work with every Dioxus renderer: web, desktop and mobile
5//! (webview), and Dioxus Native, which draws HTML and CSS with the Blitz engine instead of a
6//! webview. Interactions run in Rust, so they also work where there is no JavaScript.
7//!
8//! ```toml
9//! [dependencies]
10//! lumen-dioxus = "6.0"
11//! ```
12//!
13//! Render [`LumenStyles`] once near the root, wrap the app in [`LumenTheme`], and use the
14//! components from the [`prelude`]:
15//!
16//! ```
17//! use dioxus::prelude::*;
18//! use lumen_dioxus::prelude::*;
19//!
20//! #[component]
21//! fn App() -> Element {
22//!     rsx! {
23//!         LumenStyles {}
24//!         LumenTheme { scheme: LumenScheme::Dark,
25//!             Card {
26//!                 CardHeader {
27//!                     CardTitle { "Workspace plan" }
28//!                     CardDescription { "Shared libraries and audit logs." }
29//!                 }
30//!                 CardFooter {
31//!                     Button { variant: ButtonVariant::Secondary, "Compare plans" }
32//!                     Button { onclick: move |_| {}, "Upgrade" }
33//!                 }
34//!             }
35//!         }
36//!     }
37//! }
38//! ```
39//!
40//! Icons live in [`icons`]; brand icons need the `brand-icons` feature. On Dioxus Native,
41//! check controls render as ARIA buttons, glass needs a renderer with `backdrop-filter` support,
42//! placeholders do not show yet, and web platform APIs such as the clipboard fall back to a
43//! documented state. The crate README lists every component and the renderer notes.
44
45mod button;
46mod class;
47mod feedback;
48mod form;
49mod surface;
50mod tabs;
51
52pub mod hooks;
53pub mod icons;
54pub mod overlay;
55pub mod time;
56
57mod theme;
58
59mod charts;
60mod content;
61mod data;
62mod inputs;
63mod layout;
64mod motion;
65mod navigation;
66mod overlays;
67mod pickers;
68
69use dioxus::prelude::*;
70
71pub use button::{Button, ButtonProps, ButtonSize, ButtonTone, ButtonVariant};
72pub use class::{Glass, Orientation};
73pub use feedback::{
74    Avatar, AvatarProps, AvatarSize, Progress, ProgressProps, ProgressState, Separator,
75    SeparatorProps, Spinner, SpinnerProps, normalize_progress,
76};
77pub use form::{
78    Checkbox, CheckboxProps, ControlSize, Field, FieldError, FieldErrorProps, FieldProps, Input,
79    InputProps, Label, LabelProps, Switch, SwitchProps, Textarea, TextareaProps,
80};
81pub use surface::{
82    Alert, AlertProps, AlertVariant, Badge, BadgeProps, BadgeVariant, Card, CardContent,
83    CardDensity, CardDescription, CardFooter, CardHeader, CardPartProps, CardProps, CardTitle,
84    CardVariant,
85};
86pub use tabs::{
87    Tabs, TabsList, TabsListProps, TabsPanel, TabsPanelProps, TabsProps, TabsTrigger,
88    TabsTriggerProps,
89};
90
91pub use icons::{Icon, IconData, IconProps, IconSize};
92pub use theme::{LumenPreset, LumenScheme, LumenTheme, LumenThemeProps};
93
94pub use charts::*;
95pub use content::*;
96pub use data::*;
97pub use inputs::*;
98pub use layout::*;
99pub use motion::*;
100pub use navigation::*;
101pub use overlays::*;
102pub use pickers::*;
103
104/// Lumen's complete stylesheet, generated from `@santi020k/lumen-core`.
105///
106/// Use it when you load styles yourself; otherwise render [`LumenStyles`].
107pub const LUMEN_CSS: &str = include_str!("../assets/lumen.css");
108
109/// Embeds [`LUMEN_CSS`] in a `<style>` element. Render it once, near the root of the app.
110#[component]
111pub fn LumenStyles() -> Element {
112    rsx! {
113        style { {LUMEN_CSS} }
114    }
115}
116
117/// Everything needed to build a Lumen interface: components, their props and option enums,
118/// icons, and [`LumenStyles`].
119pub mod prelude {
120    pub use crate::icons::{self, Icon, IconData, IconSize};
121    pub use crate::{
122        Alert, AlertVariant, Avatar, AvatarSize, Badge, BadgeVariant, Button, ButtonSize,
123        ButtonTone, ButtonVariant, Card, CardContent, CardDensity, CardDescription, CardFooter,
124        CardHeader, CardTitle, CardVariant, Checkbox, ControlSize, Field, FieldError, Glass, Input,
125        Label, LumenStyles, Orientation, Progress, Separator, Spinner, Switch, Tabs, TabsList,
126        TabsPanel, TabsTrigger, Textarea,
127    };
128    pub use crate::{LumenPreset, LumenScheme, LumenTheme};
129
130    pub use crate::charts::*;
131    pub use crate::content::*;
132    pub use crate::data::*;
133    pub use crate::inputs::*;
134    pub use crate::layout::*;
135    pub use crate::motion::*;
136    pub use crate::navigation::*;
137    pub use crate::overlays::*;
138    pub use crate::pickers::*;
139}