Skip to main content

next_rust_ui/
lib.rs

1//! Ready-made UI components for Next Rust.
2//!
3//! ```
4//! use next_rust_ui::*;
5//! use next_rust_view::*;
6//!
7//! let form = form![
8//!     Input![label = "Email", name = "email", kind = "email", placeholder = "you@example.com"],
9//!     PasswordInput![label = "Password", name = "password"],
10//!     Button![color = Color::Primary, submit = true, class("w-full"), "Sign in"],
11//! ];
12//! let html = render_static(form);
13//! assert!(html.contains(r#"class="nr-btn nr-btn-solid nr-c-primary nr-btn-md w-full""#));
14//! ```
15//!
16//! Every component is a builder with a macro of the same name. Inside the
17//! macro, `key = value` sets a property and anything else is added like in an
18//! element macro: attributes (`class(..)`, `id(..)`, `aria(..)`, `data(..)`)
19//! and children. Every property is optional.
20//!
21//! Styling:
22//!
23//! * Each component has default classes (`nr-btn`, `nr-input`, ...) whose
24//!   rules live in the CSS `components` layer. Classes you add, Tailwind
25//!   utilities or your own CSS, always win over them, without `!important`.
26//! * `unstyled = true` drops the default classes of the outer element.
27//! * Colors, radii and shadows are CSS variables (`--nr-primary`,
28//!   `--nr-radius-md`, ...): set them on `:root` to theme every component.
29//!   Dark mode follows the system, or `class="dark"` / `data-theme="dark"`
30//!   on an ancestor.
31//! * Pages receive only the CSS of the components they render.
32//!
33//! Interactive components (select, date picker, password toggle, tabs with
34//! panels, modals, closable alerts, `on_press`) load a small script,
35//! `/_next-rust/ui.js`, on the pages that use them. Without it they fall
36//! back to the native control (a `<select>`, a `<dialog>`, `<details>`), so
37//! pages keep working.
38
39#![forbid(unsafe_code)]
40
41use std::borrow::Cow;
42use std::sync::atomic::{AtomicUsize, Ordering};
43
44use next_rust_view::{Attr, Element, Node, Part, Stylesheet, View};
45
46mod avatar;
47mod button;
48mod card;
49mod date_picker;
50mod display;
51mod feedback;
52mod icons;
53mod input;
54mod layout;
55mod navigation;
56mod overlay;
57mod press;
58mod script;
59mod select;
60#[doc(hidden)]
61pub mod style;
62mod table;
63mod toggle;
64
65pub use avatar::{Avatar, AvatarGroup};
66pub use button::{Button, ButtonGroup};
67pub use card::{Card, CardBody, CardFooter, CardHeader, Shadow};
68pub use date_picker::DatePicker;
69pub use display::{
70    Alert, Badge, CircularProgress, EmptyState, Kbd, Placement, Progress, Side, Skeleton, Stat, Tooltip, Trend,
71};
72pub use feedback::{Chip, Divider, Spinner};
73pub use input::{Input, LabelPlacement, PasswordInput, Textarea};
74pub use layout::{Align, AppShell, Container, Grid, Justify, Navbar, NavbarItem, Sidebar, SidebarItem, Stack, Width};
75pub use navigation::{
76    Accordion, AccordionItem, AccordionVariant, BreadcrumbItem, Breadcrumbs, Step, StepStatus, Steps, Tab, Tabs,
77    TabsVariant,
78};
79pub use overlay::{Modal, ModalBody, ModalFooter, ModalPlacement};
80pub use press::Press;
81pub use select::{Select, SelectItem};
82pub use table::Table;
83pub use toggle::{Checkbox, Radio, RadioGroup, Switch};
84
85/// The component stylesheet. Components add it to the page themselves; only
86/// the rules for the components a page renders are sent.
87pub static UI_CSS: Stylesheet = Stylesheet {
88    id: "nr-ui",
89    // `style::UI_CSS_SOURCE`, minified by `build.rs`.
90    css: include_str!(concat!(env!("OUT_DIR"), "/ui.min.css")),
91    per_class: Some(&[]),
92    scripts: &[],
93};
94
95pub use script::{UI_JS, UI_JS_MIN, rename_classes as rename_script_classes};
96
97/// Classes the components render that no stylesheet rule starts with (hooks
98/// for the script and for your own CSS). Release builds shorten them with the
99/// stylesheet's classes; `tests/components.rs` keeps the list complete.
100#[doc(hidden)]
101pub const EXTRA_CLASSES: &[&str] = &[
102    "nr-checkbox-label",
103    "nr-cols-1",
104    "nr-datepicker-toggle",
105    "nr-label-outside",
106    "nr-modal-center",
107    "nr-password",
108    "nr-radio-label",
109    "nr-shell-with-sidebar",
110    "nr-switch-label",
111    "nr-tab-title",
112];
113
114/// Color of a component.
115#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
116pub enum Color {
117    Default,
118    #[default]
119    Primary,
120    Secondary,
121    Success,
122    Warning,
123    Danger,
124}
125
126impl Color {
127    pub(crate) fn class(self) -> &'static str {
128        match self {
129            Color::Default => "nr-c-default",
130            Color::Primary => "nr-c-primary",
131            Color::Secondary => "nr-c-secondary",
132            Color::Success => "nr-c-success",
133            Color::Warning => "nr-c-warning",
134            Color::Danger => "nr-c-danger",
135        }
136    }
137}
138
139/// Size of a component.
140#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
141pub enum Size {
142    Sm,
143    #[default]
144    Md,
145    Lg,
146}
147
148impl Size {
149    pub(crate) fn suffix(self) -> &'static str {
150        match self {
151            Size::Sm => "sm",
152            Size::Md => "md",
153            Size::Lg => "lg",
154        }
155    }
156}
157
158/// Corner rounding. `None` in a builder keeps the component's own default.
159#[derive(Debug, Clone, Copy, PartialEq, Eq)]
160pub enum Radius {
161    None,
162    Sm,
163    Md,
164    Lg,
165    Full,
166}
167
168impl Radius {
169    pub(crate) fn class(self) -> &'static str {
170        match self {
171            Radius::None => "nr-r-none",
172            Radius::Sm => "nr-r-sm",
173            Radius::Md => "nr-r-md",
174            Radius::Lg => "nr-r-lg",
175            Radius::Full => "nr-r-full",
176        }
177    }
178}
179
180/// Visual style of buttons and chips.
181#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
182pub enum Variant {
183    /// Filled with the color.
184    #[default]
185    Solid,
186    /// Outlined with the color.
187    Bordered,
188    /// Transparent until hovered.
189    Light,
190    /// A soft tint of the color.
191    Flat,
192    /// Neutral fill and border, colored text.
193    Faded,
194    /// Solid with a colored glow.
195    Shadow,
196    /// Outlined, filled on hover.
197    Ghost,
198}
199
200impl Variant {
201    pub(crate) fn suffix(self) -> &'static str {
202        match self {
203            Variant::Solid => "solid",
204            Variant::Bordered => "bordered",
205            Variant::Light => "light",
206            Variant::Flat => "flat",
207            Variant::Faded => "faded",
208            Variant::Shadow => "shadow",
209            Variant::Ghost => "ghost",
210        }
211    }
212}
213
214/// Visual style of text fields, selects and date pickers.
215#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
216pub enum FieldVariant {
217    /// A soft filled box.
218    #[default]
219    Flat,
220    /// An outlined box.
221    Bordered,
222    /// Filled and outlined.
223    Faded,
224    /// Only a bottom line.
225    Underlined,
226}
227
228impl FieldVariant {
229    pub(crate) fn class(self) -> &'static str {
230        match self {
231            FieldVariant::Flat => "nr-field-flat",
232            FieldVariant::Bordered => "nr-field-bordered",
233            FieldVariant::Faded => "nr-field-faded",
234            FieldVariant::Underlined => "nr-field-underlined",
235        }
236    }
237}
238
239/// Text that may be absent: `&str`, `String` or an `Option` of either, so
240/// `error_message = form.error("email")` works as is.
241pub trait MaybeText {
242    fn into_text(self) -> Option<String>;
243}
244
245impl MaybeText for &str {
246    fn into_text(self) -> Option<String> {
247        Some(self.to_owned())
248    }
249}
250impl MaybeText for String {
251    fn into_text(self) -> Option<String> {
252        Some(self)
253    }
254}
255impl MaybeText for &String {
256    fn into_text(self) -> Option<String> {
257        Some(self.clone())
258    }
259}
260impl<T: MaybeText> MaybeText for Option<T> {
261    fn into_text(self) -> Option<String> {
262        self.and_then(MaybeText::into_text).filter(|s| !s.is_empty())
263    }
264}
265
266/// Attributes and children given to a component inside its macro.
267#[derive(Default)]
268pub(crate) struct Extra {
269    el: Option<Element>,
270}
271
272impl Extra {
273    pub(crate) fn push(&mut self, part: impl Part) {
274        part.apply(self.el.get_or_insert_with(|| Element::new("div")));
275    }
276
277    pub(crate) fn has_children(&self) -> bool {
278        self.el.as_ref().is_some_and(|el| !el.children.is_empty())
279    }
280
281    /// `(class attribute of the outer element, other attributes, children)`.
282    pub(crate) fn split(self) -> (Option<Attr>, Vec<Attr>, Vec<Node>) {
283        let Some(el) = self.el else { return (None, Vec::new(), Vec::new()) };
284        let mut class = None;
285        let mut attrs = Vec::new();
286        for a in el.attrs {
287            if a.name == "class" {
288                class = Some(a);
289            } else {
290                attrs.push(a);
291            }
292        }
293        (class, attrs, el.children)
294    }
295}
296
297/// Unique element id for labels and descriptions.
298pub(crate) fn next_id(prefix: &str) -> String {
299    static NEXT: AtomicUsize = AtomicUsize::new(0);
300    format!("{prefix}-{}", NEXT.fetch_add(1, Ordering::Relaxed))
301}
302
303/// An element with the component classes (unless unstyled), the extra class
304/// and the component stylesheet.
305pub(crate) fn root(tag: &'static str, classes: &[&str], unstyled: bool, extra: Option<Attr>) -> Element {
306    let mut el = Element::new(tag);
307    if !unstyled {
308        el.set_attr(Attr::new(
309            "class",
310            classes.iter().filter(|c| !c.is_empty()).copied().collect::<Vec<_>>().join(" "),
311        ));
312    }
313    if let Some(class) = extra {
314        el.set_attr(class);
315    }
316    el
317}
318
319/// `class="…"` for an inner part: its default class plus the one given for it.
320pub(crate) fn part_class(default: &str, extra: &Option<String>) -> Attr {
321    match extra {
322        Some(e) => Attr::new("class", format!("{default} {e}")),
323        None => Attr::new("class", default.to_owned()),
324    }
325}
326
327pub(crate) fn attr(name: &'static str, value: impl Into<Cow<'static, str>>) -> Attr {
328    Attr::new(name, value)
329}
330
331pub(crate) fn flag(name: &'static str, on: bool) -> Attr {
332    Attr::boolean(name, on)
333}
334
335/// Apply attributes to an element (`class` merges, others replace).
336pub(crate) fn apply(el: &mut Element, attrs: Vec<Attr>) {
337    for a in attrs {
338        el.set_attr(a);
339    }
340}
341
342/// The element plus the stylesheet, as a node.
343pub(crate) fn styled(el: Element) -> Node {
344    Node::Fragment(vec![Node::Style(&UI_CSS), el.into_node()])
345}
346
347/// Set properties and add parts: `ui!(Button::new(), color = Color::Primary, class("x"), "Save")`.
348///
349/// The component macros (`Button!`, `Input!`, ...) are built on this.
350#[doc(hidden)]
351#[macro_export]
352macro_rules! __ui_munch {
353    ([$($acc:tt)*]) => { $($acc)* };
354    ([$($acc:tt)*] $key:ident = $val:expr $(, $($rest:tt)*)?) => {
355        $crate::__ui_munch!([$($acc)*.$key($val)] $($($rest)*)?)
356    };
357    ([$($acc:tt)*] $part:expr $(, $($rest:tt)*)?) => {
358        $crate::__ui_munch!([$($acc)*.with($part)] $($($rest)*)?)
359    };
360}
361
362/// Build a [`AppShell`](struct@crate::AppShell): `key = value` sets a property, anything else is
363/// added as an attribute or child.
364#[macro_export]
365macro_rules! AppShell {
366    ($($body:tt)*) => { $crate::__ui_munch!([$crate::AppShell::new()] $($body)*) };
367}
368
369/// Build a [`Avatar`](struct@crate::Avatar): `key = value` sets a property, anything else is
370/// added as an attribute or child.
371#[macro_export]
372macro_rules! Avatar {
373    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Avatar::new()] $($body)*) };
374}
375
376/// Build a [`AvatarGroup`](struct@crate::AvatarGroup): `key = value` sets a property, anything else is
377/// added as an attribute or child.
378#[macro_export]
379macro_rules! AvatarGroup {
380    ($($body:tt)*) => { $crate::__ui_munch!([$crate::AvatarGroup::new()] $($body)*) };
381}
382
383/// Build a [`Button`](struct@crate::Button): `key = value` sets a property, anything else is
384/// added as an attribute or child.
385#[macro_export]
386macro_rules! Button {
387    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Button::new()] $($body)*) };
388}
389
390/// Build a [`ButtonGroup`](struct@crate::ButtonGroup): `key = value` sets a property, anything else is
391/// added as an attribute or child.
392#[macro_export]
393macro_rules! ButtonGroup {
394    ($($body:tt)*) => { $crate::__ui_munch!([$crate::ButtonGroup::new()] $($body)*) };
395}
396
397/// Build a [`Card`](struct@crate::Card): `key = value` sets a property, anything else is
398/// added as an attribute or child.
399#[macro_export]
400macro_rules! Card {
401    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Card::new()] $($body)*) };
402}
403
404/// Build a [`CardBody`](struct@crate::CardBody): `key = value` sets a property, anything else is
405/// added as an attribute or child.
406#[macro_export]
407macro_rules! CardBody {
408    ($($body:tt)*) => { $crate::__ui_munch!([$crate::CardBody::new()] $($body)*) };
409}
410
411/// Build a [`CardFooter`](struct@crate::CardFooter): `key = value` sets a property, anything else is
412/// added as an attribute or child.
413#[macro_export]
414macro_rules! CardFooter {
415    ($($body:tt)*) => { $crate::__ui_munch!([$crate::CardFooter::new()] $($body)*) };
416}
417
418/// Build a [`CardHeader`](struct@crate::CardHeader): `key = value` sets a property, anything else is
419/// added as an attribute or child.
420#[macro_export]
421macro_rules! CardHeader {
422    ($($body:tt)*) => { $crate::__ui_munch!([$crate::CardHeader::new()] $($body)*) };
423}
424
425/// Build a [`Checkbox`](struct@crate::Checkbox): `key = value` sets a property, anything else is
426/// added as an attribute or child.
427#[macro_export]
428macro_rules! Checkbox {
429    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Checkbox::new()] $($body)*) };
430}
431
432/// Build a [`Chip`](struct@crate::Chip): `key = value` sets a property, anything else is
433/// added as an attribute or child.
434#[macro_export]
435macro_rules! Chip {
436    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Chip::new()] $($body)*) };
437}
438
439/// Build a [`Container`](struct@crate::Container): `key = value` sets a property, anything else is
440/// added as an attribute or child.
441#[macro_export]
442macro_rules! Container {
443    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Container::new()] $($body)*) };
444}
445
446/// Build a [`DatePicker`](struct@crate::DatePicker): `key = value` sets a property, anything else is
447/// added as an attribute or child.
448#[macro_export]
449macro_rules! DatePicker {
450    ($($body:tt)*) => { $crate::__ui_munch!([$crate::DatePicker::new()] $($body)*) };
451}
452
453/// Build a [`Divider`](struct@crate::Divider): `key = value` sets a property, anything else is
454/// added as an attribute or child.
455#[macro_export]
456macro_rules! Divider {
457    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Divider::new()] $($body)*) };
458}
459
460/// Build a [`Grid`](struct@crate::Grid): `key = value` sets a property, anything else is
461/// added as an attribute or child.
462#[macro_export]
463macro_rules! Grid {
464    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Grid::new()] $($body)*) };
465}
466
467/// Build a [`Input`](struct@crate::Input): `key = value` sets a property, anything else is
468/// added as an attribute or child.
469#[macro_export]
470macro_rules! Input {
471    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Input::new()] $($body)*) };
472}
473
474/// Build a [`Navbar`](struct@crate::Navbar): `key = value` sets a property, anything else is
475/// added as an attribute or child.
476#[macro_export]
477macro_rules! Navbar {
478    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Navbar::new()] $($body)*) };
479}
480
481/// Build a [`NavbarItem`](struct@crate::NavbarItem): `key = value` sets a property, anything else is
482/// added as an attribute or child.
483#[macro_export]
484macro_rules! NavbarItem {
485    ($($body:tt)*) => { $crate::__ui_munch!([$crate::NavbarItem::new()] $($body)*) };
486}
487
488/// Build a [`PasswordInput`](struct@crate::PasswordInput): `key = value` sets a property, anything else is
489/// added as an attribute or child.
490#[macro_export]
491macro_rules! PasswordInput {
492    ($($body:tt)*) => { $crate::__ui_munch!([$crate::PasswordInput::new()] $($body)*) };
493}
494
495/// Build a [`Radio`](struct@crate::Radio): `key = value` sets a property, anything else is
496/// added as an attribute or child.
497#[macro_export]
498macro_rules! Radio {
499    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Radio::new()] $($body)*) };
500}
501
502/// Build a [`RadioGroup`](struct@crate::RadioGroup): `key = value` sets a property, anything else is
503/// added as an attribute or child.
504#[macro_export]
505macro_rules! RadioGroup {
506    ($($body:tt)*) => { $crate::__ui_munch!([$crate::RadioGroup::new()] $($body)*) };
507}
508
509/// Build a [`Select`](struct@crate::Select): `key = value` sets a property, anything else is
510/// added as an attribute or child.
511#[macro_export]
512macro_rules! Select {
513    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Select::new()] $($body)*) };
514}
515
516/// Build a [`SelectItem`](struct@crate::SelectItem): `key = value` sets a property, anything else is
517/// added as an attribute or child.
518#[macro_export]
519macro_rules! SelectItem {
520    ($($body:tt)*) => { $crate::__ui_munch!([$crate::SelectItem::new()] $($body)*) };
521}
522
523/// Build a [`Sidebar`](struct@crate::Sidebar): `key = value` sets a property, anything else is
524/// added as an attribute or child.
525#[macro_export]
526macro_rules! Sidebar {
527    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Sidebar::new()] $($body)*) };
528}
529
530/// Build a [`SidebarItem`](struct@crate::SidebarItem): `key = value` sets a property, anything else is
531/// added as an attribute or child.
532#[macro_export]
533macro_rules! SidebarItem {
534    ($($body:tt)*) => { $crate::__ui_munch!([$crate::SidebarItem::new()] $($body)*) };
535}
536
537/// Build a [`Spinner`](struct@crate::Spinner): `key = value` sets a property, anything else is
538/// added as an attribute or child.
539#[macro_export]
540macro_rules! Spinner {
541    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Spinner::new()] $($body)*) };
542}
543
544/// Build a [`Stack`](struct@crate::Stack): `key = value` sets a property, anything else is
545/// added as an attribute or child.
546#[macro_export]
547macro_rules! Stack {
548    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Stack::new()] $($body)*) };
549}
550
551/// Build a [`Switch`](struct@crate::Switch): `key = value` sets a property, anything else is
552/// added as an attribute or child.
553#[macro_export]
554macro_rules! Switch {
555    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Switch::new()] $($body)*) };
556}
557
558/// Build a [`Textarea`](struct@crate::Textarea): `key = value` sets a property, anything else is
559/// added as an attribute or child.
560#[macro_export]
561macro_rules! Textarea {
562    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Textarea::new()] $($body)*) };
563}
564
565/// Build a [`Accordion`](struct@crate::Accordion): `key = value` sets a property, anything else is
566/// added as an attribute or child.
567#[macro_export]
568macro_rules! Accordion {
569    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Accordion::new()] $($body)*) };
570}
571
572/// Build a [`AccordionItem`](struct@crate::AccordionItem): `key = value` sets a property, anything else is
573/// added as an attribute or child.
574#[macro_export]
575macro_rules! AccordionItem {
576    ($($body:tt)*) => { $crate::__ui_munch!([$crate::AccordionItem::new()] $($body)*) };
577}
578
579/// Build a [`Alert`](struct@crate::Alert): `key = value` sets a property, anything else is
580/// added as an attribute or child.
581#[macro_export]
582macro_rules! Alert {
583    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Alert::new()] $($body)*) };
584}
585
586/// Build a [`Badge`](struct@crate::Badge): `key = value` sets a property, anything else is
587/// added as an attribute or child.
588#[macro_export]
589macro_rules! Badge {
590    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Badge::new()] $($body)*) };
591}
592
593/// Build a [`BreadcrumbItem`](struct@crate::BreadcrumbItem): `key = value` sets a property, anything else is
594/// added as an attribute or child.
595#[macro_export]
596macro_rules! BreadcrumbItem {
597    ($($body:tt)*) => { $crate::__ui_munch!([$crate::BreadcrumbItem::new()] $($body)*) };
598}
599
600/// Build a [`Breadcrumbs`](struct@crate::Breadcrumbs): `key = value` sets a property, anything else is
601/// added as an attribute or child.
602#[macro_export]
603macro_rules! Breadcrumbs {
604    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Breadcrumbs::new()] $($body)*) };
605}
606
607/// Build a [`CircularProgress`](struct@crate::CircularProgress): `key = value` sets a property, anything else is
608/// added as an attribute or child.
609#[macro_export]
610macro_rules! CircularProgress {
611    ($($body:tt)*) => { $crate::__ui_munch!([$crate::CircularProgress::new()] $($body)*) };
612}
613
614/// Build a [`EmptyState`](struct@crate::EmptyState): `key = value` sets a property, anything else is
615/// added as an attribute or child.
616#[macro_export]
617macro_rules! EmptyState {
618    ($($body:tt)*) => { $crate::__ui_munch!([$crate::EmptyState::new()] $($body)*) };
619}
620
621/// Build a [`Kbd`](struct@crate::Kbd): `key = value` sets a property, anything else is
622/// added as an attribute or child.
623#[macro_export]
624macro_rules! Kbd {
625    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Kbd::new()] $($body)*) };
626}
627
628/// Build a [`Modal`](struct@crate::Modal): `key = value` sets a property, anything else is
629/// added as an attribute or child.
630#[macro_export]
631macro_rules! Modal {
632    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Modal::new()] $($body)*) };
633}
634
635/// Build a [`ModalBody`](struct@crate::ModalBody): `key = value` sets a property, anything else is
636/// added as an attribute or child.
637#[macro_export]
638macro_rules! ModalBody {
639    ($($body:tt)*) => { $crate::__ui_munch!([$crate::ModalBody::new()] $($body)*) };
640}
641
642/// Build a [`ModalFooter`](struct@crate::ModalFooter): `key = value` sets a property, anything else is
643/// added as an attribute or child.
644#[macro_export]
645macro_rules! ModalFooter {
646    ($($body:tt)*) => { $crate::__ui_munch!([$crate::ModalFooter::new()] $($body)*) };
647}
648
649/// Build a [`Progress`](struct@crate::Progress): `key = value` sets a property, anything else is
650/// added as an attribute or child.
651#[macro_export]
652macro_rules! Progress {
653    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Progress::new()] $($body)*) };
654}
655
656/// Build a [`Skeleton`](struct@crate::Skeleton): `key = value` sets a property, anything else is
657/// added as an attribute or child.
658#[macro_export]
659macro_rules! Skeleton {
660    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Skeleton::new()] $($body)*) };
661}
662
663/// Build a [`Stat`](struct@crate::Stat): `key = value` sets a property, anything else is
664/// added as an attribute or child.
665#[macro_export]
666macro_rules! Stat {
667    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Stat::new()] $($body)*) };
668}
669
670/// Build a [`Step`](struct@crate::Step): `key = value` sets a property, anything else is
671/// added as an attribute or child.
672#[macro_export]
673macro_rules! Step {
674    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Step::new()] $($body)*) };
675}
676
677/// Build a [`Steps`](struct@crate::Steps): `key = value` sets a property, anything else is
678/// added as an attribute or child.
679#[macro_export]
680macro_rules! Steps {
681    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Steps::new()] $($body)*) };
682}
683
684/// Build a [`Tab`](struct@crate::Tab): `key = value` sets a property, anything else is
685/// added as an attribute or child.
686#[macro_export]
687macro_rules! Tab {
688    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Tab::new()] $($body)*) };
689}
690
691/// Build a [`Table`](struct@crate::Table): `key = value` sets a property, anything else is
692/// added as an attribute or child.
693#[macro_export]
694macro_rules! Table {
695    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Table::new()] $($body)*) };
696}
697
698/// Build a [`Tabs`](struct@crate::Tabs): `key = value` sets a property, anything else is
699/// added as an attribute or child.
700#[macro_export]
701macro_rules! Tabs {
702    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Tabs::new()] $($body)*) };
703}
704
705/// Build a [`Tooltip`](struct@crate::Tooltip): `key = value` sets a property, anything else is
706/// added as an attribute or child.
707#[macro_export]
708macro_rules! Tooltip {
709    ($($body:tt)*) => { $crate::__ui_munch!([$crate::Tooltip::new()] $($body)*) };
710}