Skip to main content

lumen_dioxus/layout/
structure.rs

1//! Structural layout: `AspectRatio`, `Container`, `Direction`, `Grid`, `Stack`, `Prose`,
2//! `VisuallyHidden`, `GradientDivider`, `ScrollArea`, `Toolbar`, `Affix`, and `Watermark`.
3
4use dioxus::prelude::*;
5
6use super::util::{
7    ContainerElement, GridElement, StackElement, attr, element, encode_uri_component, escape_xml,
8    join_style, js_number,
9};
10use crate::class::{Glass, Orientation, compose};
11
12/// Props for [`AspectRatio`].
13#[derive(Props, Clone, PartialEq)]
14pub struct AspectRatioProps {
15    /// CSS `aspect-ratio` value. Defaults to `16 / 9`.
16    #[props(default = "16 / 9".to_string(), into)]
17    pub ratio: String,
18    /// Inline style appended after the ratio, so it can override it.
19    #[props(into)]
20    pub style: Option<String>,
21    /// Extra classes appended after the Lumen class.
22    #[props(into)]
23    pub class: Option<String>,
24    /// Any other `<div>` or global attribute.
25    #[props(extends = GlobalAttributes, extends = div)]
26    pub attributes: Vec<Attribute>,
27    /// Media or content kept at the ratio.
28    pub children: Element,
29}
30
31/// Keeps its content at a fixed width-to-height ratio.
32#[component]
33pub fn AspectRatio(props: AspectRatioProps) -> Element {
34    let class = compose([Some("ui-aspect-ratio"), props.class.as_deref()]);
35    let ratio = format!("aspect-ratio: {}", props.ratio);
36    let style = join_style([Some(ratio.as_str()), props.style.as_deref()]);
37
38    rsx! {
39        div { class, style, ..props.attributes, {props.children} }
40    }
41}
42
43/// Maximum width of a [`Container`].
44#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
45#[non_exhaustive]
46pub enum ContainerSize {
47    /// Narrow reading width.
48    Sm,
49    /// Medium width.
50    Md,
51    /// The default page width.
52    #[default]
53    Lg,
54    /// No maximum width.
55    Full,
56}
57
58impl ContainerSize {
59    /// The class suffix and `data-size` value.
60    pub fn as_str(self) -> &'static str {
61        match self {
62            Self::Sm => "sm",
63            Self::Md => "md",
64            Self::Lg => "lg",
65            Self::Full => "full",
66        }
67    }
68}
69
70/// Props for [`Container`].
71#[derive(Props, Clone, PartialEq)]
72pub struct ContainerProps {
73    /// Maximum width.
74    #[props(default)]
75    pub size: ContainerSize,
76    /// The rendered element. Defaults to `<div>`.
77    #[props(default)]
78    pub r#as: ContainerElement,
79    /// Extra classes appended after the Lumen classes.
80    #[props(into)]
81    pub class: Option<String>,
82    /// Any other global attribute.
83    #[props(extends = GlobalAttributes, extends = div)]
84    pub attributes: Vec<Attribute>,
85    /// Page content.
86    pub children: Element,
87}
88
89/// Centers page content and caps its width.
90#[component]
91pub fn Container(props: ContainerProps) -> Element {
92    let size = props.size.as_str();
93    let modifier = format!("ui-container--{size}");
94    let class = compose([
95        Some("ui-container"),
96        Some(modifier.as_str()),
97        props.class.as_deref(),
98    ]);
99    let mut attributes = vec![
100        attr("class", class),
101        attr("data-size", size),
102        attr("data-ui-container", "true"),
103    ];
104    attributes.extend(props.attributes);
105
106    element(props.r#as, attributes, props.children)
107}
108
109/// Text direction set by [`Direction`].
110#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
111#[non_exhaustive]
112pub enum DirectionValue {
113    /// Left to right.
114    #[default]
115    Ltr,
116    /// Right to left.
117    Rtl,
118    /// Decided by the content.
119    Auto,
120}
121
122impl DirectionValue {
123    /// The `dir` attribute value.
124    pub fn as_str(self) -> &'static str {
125        match self {
126            Self::Ltr => "ltr",
127            Self::Rtl => "rtl",
128            Self::Auto => "auto",
129        }
130    }
131
132    /// Whether arrow keys and drag deltas flip horizontally.
133    pub fn is_rtl(self) -> bool {
134        self == Self::Rtl
135    }
136}
137
138#[derive(Clone, Copy)]
139struct DirectionContext(Signal<DirectionValue>);
140
141/// The direction of the nearest [`Direction`] ancestor, or [`DirectionValue::Ltr`] without one.
142///
143/// `Resizable`, `KanbanBoard`, and `Carousel` read it to flip horizontal arrow keys in
144/// right-to-left layouts, the way `@santi020k/lumen-react` reads the computed `direction`.
145pub fn use_direction() -> DirectionValue {
146    try_use_context::<DirectionContext>().map_or(DirectionValue::Ltr, |context| (context.0)())
147}
148
149/// Props for [`Direction`].
150#[derive(Props, Clone, PartialEq)]
151pub struct DirectionProps {
152    /// Text direction for the subtree. Defaults to left to right.
153    #[props(default)]
154    pub dir: DirectionValue,
155    /// Extra classes appended after the Lumen class.
156    #[props(into)]
157    pub class: Option<String>,
158    /// Any other `<div>` or global attribute.
159    #[props(extends = GlobalAttributes, extends = div)]
160    pub attributes: Vec<Attribute>,
161    /// Content laid out in the direction.
162    pub children: Element,
163}
164
165/// Sets `dir` on a wrapper and shares it with descendants through [`use_direction`].
166#[component]
167pub fn Direction(props: DirectionProps) -> Element {
168    let mut current = use_signal(|| props.dir);
169    use_context_provider(|| DirectionContext(current));
170
171    if *current.peek() != props.dir {
172        current.set(props.dir);
173    }
174
175    let class = compose([Some("ui-direction"), props.class.as_deref()]);
176
177    rsx! {
178        div { class, dir: props.dir.as_str(), ..props.attributes, {props.children} }
179    }
180}
181
182/// Column count of a [`Grid`].
183#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
184#[non_exhaustive]
185pub enum GridColumns {
186    /// One column.
187    One,
188    /// Two columns.
189    Two,
190    /// Three columns.
191    Three,
192    /// Four columns.
193    Four,
194    /// Six columns.
195    Six,
196    /// Twelve columns.
197    Twelve,
198    /// As many columns as fit the minimum item width.
199    #[default]
200    Auto,
201}
202
203impl GridColumns {
204    /// The class suffix and `data-columns` value.
205    pub fn as_str(self) -> &'static str {
206        match self {
207            Self::One => "1",
208            Self::Two => "2",
209            Self::Three => "3",
210            Self::Four => "4",
211            Self::Six => "6",
212            Self::Twelve => "12",
213            Self::Auto => "auto",
214        }
215    }
216}
217
218/// Gap between [`Grid`] and [`Stack`] children, from Lumen's spacing scale.
219#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
220#[non_exhaustive]
221pub enum GridGap {
222    /// No gap.
223    None,
224    /// Extra small.
225    Xs,
226    /// Small.
227    Sm,
228    /// Medium.
229    Md,
230    /// Large.
231    Lg,
232    /// Extra large.
233    Xl,
234    /// Two times extra large.
235    Xl2,
236    /// Three times extra large.
237    Xl3,
238    /// Space between closely related items.
239    Related,
240    /// Space between groups. The default.
241    #[default]
242    Group,
243    /// Space between sections.
244    Section,
245}
246
247impl GridGap {
248    /// The class suffix.
249    pub fn as_str(self) -> &'static str {
250        match self {
251            Self::None => "none",
252            Self::Xs => "xs",
253            Self::Sm => "sm",
254            Self::Md => "md",
255            Self::Lg => "lg",
256            Self::Xl => "xl",
257            Self::Xl2 => "2xl",
258            Self::Xl3 => "3xl",
259            Self::Related => "related",
260            Self::Group => "group",
261            Self::Section => "section",
262        }
263    }
264}
265
266/// Gap between [`Stack`] children.
267pub type StackGap = GridGap;
268
269/// Props for [`Grid`].
270#[derive(Props, Clone, PartialEq)]
271pub struct GridProps {
272    /// Column count.
273    #[props(default)]
274    pub columns: GridColumns,
275    /// Gap between items.
276    #[props(default)]
277    pub gap: GridGap,
278    /// Minimum item width for automatic columns, as a CSS length.
279    #[props(into)]
280    pub min_item_width: Option<String>,
281    /// The rendered element. Defaults to `<div>`.
282    #[props(default)]
283    pub r#as: GridElement,
284    /// Inline style. The minimum item width is appended after it.
285    #[props(into)]
286    pub style: Option<String>,
287    /// Extra classes appended after the Lumen classes.
288    #[props(into)]
289    pub class: Option<String>,
290    /// Any other global attribute.
291    #[props(extends = GlobalAttributes, extends = div)]
292    pub attributes: Vec<Attribute>,
293    /// Grid items.
294    pub children: Element,
295}
296
297/// A responsive CSS grid on Lumen's spacing scale.
298#[component]
299pub fn Grid(props: GridProps) -> Element {
300    let columns = props.columns.as_str();
301    let columns_class = format!("ui-grid--columns-{columns}");
302    let gap_class = format!("ui-grid--gap-{}", props.gap.as_str());
303    let class = compose([
304        Some("ui-grid"),
305        Some(columns_class.as_str()),
306        Some(gap_class.as_str()),
307        props.class.as_deref(),
308    ]);
309    let min = props
310        .min_item_width
311        .as_deref()
312        .map(|width| format!("--ui-grid-min: {width}"));
313    let mut attributes = vec![
314        attr("class", class),
315        attr("data-columns", columns),
316        attr("data-ui-grid", "true"),
317    ];
318
319    if let Some(style) = join_style([props.style.as_deref(), min.as_deref()]) {
320        attributes.push(attr("style", style));
321    }
322
323    attributes.extend(props.attributes);
324
325    element(props.r#as, attributes, props.children)
326}
327
328/// Cross-axis alignment of [`Stack`] children.
329#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
330#[non_exhaustive]
331pub enum StackAlign {
332    /// Align to the start.
333    Start,
334    /// Center.
335    Center,
336    /// Align to the end.
337    End,
338    /// Stretch to fill. The default.
339    #[default]
340    Stretch,
341}
342
343impl StackAlign {
344    /// The class suffix.
345    pub fn as_str(self) -> &'static str {
346        match self {
347            Self::Start => "start",
348            Self::Center => "center",
349            Self::End => "end",
350            Self::Stretch => "stretch",
351        }
352    }
353}
354
355/// Main-axis distribution of [`Stack`] children.
356#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
357#[non_exhaustive]
358pub enum StackJustify {
359    /// Pack at the start. The default.
360    #[default]
361    Start,
362    /// Center.
363    Center,
364    /// Pack at the end.
365    End,
366    /// Spread with space between.
367    Between,
368}
369
370impl StackJustify {
371    /// The class suffix.
372    pub fn as_str(self) -> &'static str {
373        match self {
374            Self::Start => "start",
375            Self::Center => "center",
376            Self::End => "end",
377            Self::Between => "between",
378        }
379    }
380}
381
382/// Props for [`Stack`].
383#[derive(Props, Clone, PartialEq)]
384pub struct StackProps {
385    /// Main axis. Defaults to vertical.
386    #[props(default = Orientation::Vertical)]
387    pub direction: Orientation,
388    /// Gap between children.
389    #[props(default)]
390    pub gap: StackGap,
391    /// Cross-axis alignment.
392    #[props(default)]
393    pub align: StackAlign,
394    /// Main-axis distribution.
395    #[props(default)]
396    pub justify: StackJustify,
397    /// Wraps children onto new lines.
398    #[props(default)]
399    pub wrap: bool,
400    /// The rendered element. Defaults to `<div>`.
401    #[props(default)]
402    pub r#as: StackElement,
403    /// Extra classes appended after the Lumen classes.
404    #[props(into)]
405    pub class: Option<String>,
406    /// Any other global attribute.
407    #[props(extends = GlobalAttributes, extends = div)]
408    pub attributes: Vec<Attribute>,
409    /// Stacked children.
410    pub children: Element,
411}
412
413/// A one-dimensional flex layout on Lumen's spacing scale.
414#[component]
415pub fn Stack(props: StackProps) -> Element {
416    let direction = props.direction.as_str();
417    let direction_class = format!("ui-stack--{direction}");
418    let gap_class = format!("ui-stack--gap-{}", props.gap.as_str());
419    let align_class = format!("ui-stack--align-{}", props.align.as_str());
420    let justify_class = format!("ui-stack--justify-{}", props.justify.as_str());
421    let class = compose([
422        Some("ui-stack"),
423        Some(direction_class.as_str()),
424        Some(gap_class.as_str()),
425        Some(align_class.as_str()),
426        Some(justify_class.as_str()),
427        props.wrap.then_some("ui-stack--wrap"),
428        props.class.as_deref(),
429    ]);
430    let mut attributes = vec![
431        attr("class", class),
432        attr("data-direction", direction),
433        attr("data-ui-stack", "true"),
434    ];
435    attributes.extend(props.attributes);
436
437    element(props.r#as, attributes, props.children)
438}
439
440/// Typography treatment of [`Prose`].
441#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
442#[non_exhaustive]
443pub enum ProseAppearance {
444    /// Product documentation rhythm.
445    #[default]
446    Default,
447    /// Long-form editorial rhythm.
448    Editorial,
449}
450
451/// Props for [`Prose`].
452#[derive(Props, Clone, PartialEq)]
453pub struct ProseProps {
454    /// Typography treatment.
455    #[props(default)]
456    pub appearance: ProseAppearance,
457    /// Extra classes appended after the Lumen classes.
458    #[props(into)]
459    pub class: Option<String>,
460    /// Any other `<div>` or global attribute.
461    #[props(extends = GlobalAttributes, extends = div)]
462    pub attributes: Vec<Attribute>,
463    /// Rich text such as headings, paragraphs, and lists.
464    pub children: Element,
465}
466
467/// Styles plain HTML content such as rendered Markdown.
468#[component]
469pub fn Prose(props: ProseProps) -> Element {
470    let class = compose([
471        Some("ui-prose"),
472        (props.appearance == ProseAppearance::Editorial).then_some("ui-prose--editorial"),
473        props.class.as_deref(),
474    ]);
475
476    rsx! {
477        div { class, "data-slot": "prose", ..props.attributes, {props.children} }
478    }
479}
480
481/// Props for [`VisuallyHidden`].
482#[derive(Props, Clone, PartialEq)]
483pub struct VisuallyHiddenProps {
484    /// Shows the content while it has keyboard focus, for skip links.
485    #[props(default)]
486    pub focusable: bool,
487    /// Extra classes appended after the Lumen classes.
488    #[props(into)]
489    pub class: Option<String>,
490    /// Any other `<span>` or global attribute.
491    #[props(extends = GlobalAttributes, extends = span)]
492    pub attributes: Vec<Attribute>,
493    /// Text for assistive technology.
494    pub children: Element,
495}
496
497/// Hides content visually while keeping it available to assistive technology.
498#[component]
499pub fn VisuallyHidden(props: VisuallyHiddenProps) -> Element {
500    let class = compose([
501        Some("ui-visually-hidden"),
502        props.focusable.then_some("ui-visually-hidden--focusable"),
503        props.class.as_deref(),
504    ]);
505
506    rsx! {
507        span { class, "data-ui-visually-hidden": "true", ..props.attributes, {props.children} }
508    }
509}
510
511/// Props for [`GradientDivider`].
512#[derive(Props, Clone, PartialEq)]
513pub struct GradientDividerProps {
514    /// Extra classes appended after the Lumen classes.
515    #[props(into)]
516    pub class: Option<String>,
517    /// Any other `<div>` or global attribute.
518    #[props(extends = GlobalAttributes, extends = div)]
519    pub attributes: Vec<Attribute>,
520}
521
522/// The utility classes `@santi020k/lumen-react` puts on the divider line, kept byte for byte.
523const GRADIENT_DIVIDER_LINE: &str = "\n        via-brand/40 h-px w-full max-w-5xl bg-linear-to-r from-transparent\n        to-transparent\n      ";
524
525/// A decorative horizontal rule that fades in from both sides.
526#[component]
527pub fn GradientDivider(props: GradientDividerProps) -> Element {
528    let class = compose([
529        Some("ui-gradient-divider pointer-events-none flex justify-center"),
530        props.class.as_deref(),
531    ]);
532
533    rsx! {
534        div { aria_hidden: "true", class, ..props.attributes,
535            div { class: GRADIENT_DIVIDER_LINE }
536        }
537    }
538}
539
540/// Props for [`ScrollArea`].
541#[derive(Props, Clone, PartialEq)]
542pub struct ScrollAreaProps {
543    /// Glass intensity.
544    #[props(default, into)]
545    pub glass: Glass,
546    /// Extra classes appended after the Lumen classes.
547    #[props(into)]
548    pub class: Option<String>,
549    /// Any other `<div>` or global attribute. Name the region with `aria_label`.
550    #[props(extends = GlobalAttributes, extends = div)]
551    pub attributes: Vec<Attribute>,
552    /// Scrollable content.
553    pub children: Element,
554}
555
556/// A bordered region that scrolls its overflowing content.
557#[component]
558pub fn ScrollArea(props: ScrollAreaProps) -> Element {
559    let glass = props.glass.class("ui-scroll-area");
560    let class = compose([
561        Some("ui-scroll-area"),
562        glass.as_deref(),
563        props.class.as_deref(),
564    ]);
565
566    rsx! {
567        div { class, ..props.attributes, {props.children} }
568    }
569}
570
571/// Props for [`Toolbar`].
572#[derive(Props, Clone, PartialEq)]
573pub struct ToolbarProps {
574    /// Accessible name. Defaults to `Toolbar`.
575    #[props(default = "Toolbar".to_string(), into)]
576    pub aria_label: String,
577    /// Layout direction.
578    #[props(default)]
579    pub orientation: Orientation,
580    /// Extra classes appended after the Lumen classes.
581    #[props(into)]
582    pub class: Option<String>,
583    /// Any other `<div>` or global attribute.
584    #[props(extends = GlobalAttributes, extends = div)]
585    pub attributes: Vec<Attribute>,
586    /// Buttons and controls.
587    pub children: Element,
588}
589
590/// A labelled group of controls with the `toolbar` role.
591#[component]
592pub fn Toolbar(props: ToolbarProps) -> Element {
593    let orientation = props.orientation.as_str();
594    let class = compose([
595        Some("ui-toolbar"),
596        (props.orientation == Orientation::Vertical).then_some("ui-toolbar--vertical"),
597        props.class.as_deref(),
598    ]);
599
600    rsx! {
601        div {
602            aria_label: props.aria_label,
603            aria_orientation: orientation,
604            class,
605            "data-orientation": orientation,
606            "data-ui-toolbar": "true",
607            role: "toolbar",
608            ..props.attributes,
609            {props.children}
610        }
611    }
612}
613
614/// Edge an [`Affix`] sticks to.
615#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
616pub enum AffixPosition {
617    /// Sticks to the top of the scroll container.
618    #[default]
619    Top,
620    /// Sticks to the bottom of the scroll container.
621    Bottom,
622}
623
624impl AffixPosition {
625    /// The `data-position` value.
626    pub fn as_str(self) -> &'static str {
627        match self {
628            Self::Top => "top",
629            Self::Bottom => "bottom",
630        }
631    }
632}
633
634/// Props for [`Affix`].
635#[derive(Props, Clone, PartialEq)]
636pub struct AffixProps {
637    /// Distance from the edge in pixels when neither `offset_top` nor `offset_bottom` is set.
638    #[props(default)]
639    pub offset: f64,
640    /// Distance from the top in pixels.
641    pub offset_top: Option<f64>,
642    /// Distance from the bottom in pixels. Setting it sticks to the bottom.
643    pub offset_bottom: Option<f64>,
644    /// Edge to stick to. Defaults to the bottom when `offset_bottom` is set, else the top.
645    pub position: Option<AffixPosition>,
646    /// Inline style appended after the offset.
647    #[props(into)]
648    pub style: Option<String>,
649    /// Extra classes appended after the Lumen classes.
650    #[props(into)]
651    pub class: Option<String>,
652    /// Any other `<div>` or global attribute.
653    #[props(extends = GlobalAttributes, extends = div)]
654    pub attributes: Vec<Attribute>,
655    /// Content that sticks while its container scrolls.
656    pub children: Element,
657}
658
659/// Keeps content stuck to an edge while its scroll container moves, with `position: sticky`.
660#[component]
661pub fn Affix(props: AffixProps) -> Element {
662    let position = props.position.unwrap_or(if props.offset_bottom.is_some() {
663        AffixPosition::Bottom
664    } else {
665        AffixPosition::Top
666    });
667    let offset = props
668        .offset_bottom
669        .or(props.offset_top)
670        .unwrap_or(props.offset);
671    let class = compose([
672        Some("ui-affix"),
673        (position == AffixPosition::Bottom).then_some("ui-affix--bottom"),
674        props.class.as_deref(),
675    ]);
676    let offset = format!("--ui-affix-offset: {}px", js_number(offset));
677    let style = join_style([Some(offset.as_str()), props.style.as_deref()]);
678
679    rsx! {
680        div {
681            class,
682            "data-position": position.as_str(),
683            style,
684            ..props.attributes,
685            {props.children}
686        }
687    }
688}
689
690/// Props for [`Watermark`].
691#[derive(Props, Clone, PartialEq)]
692pub struct WatermarkProps {
693    /// Watermark text. Takes precedence over `text`.
694    #[props(into)]
695    pub content: Option<String>,
696    /// Watermark text when `content` is unset. Defaults to `Confidential`.
697    #[props(default = "Confidential".to_string(), into)]
698    pub text: String,
699    /// Tile size in pixels. Values below 1 use 1.
700    #[props(default = 120.0)]
701    pub gap: f64,
702    /// Text rotation in degrees.
703    #[props(default = -22.0)]
704    pub rotate: f64,
705    /// Inline style appended after the watermark variables.
706    #[props(into)]
707    pub style: Option<String>,
708    /// Extra classes appended after the Lumen class.
709    #[props(into)]
710    pub class: Option<String>,
711    /// Any other `<div>` or global attribute.
712    #[props(extends = GlobalAttributes, extends = div)]
713    pub attributes: Vec<Attribute>,
714    /// Protected content.
715    pub children: Element,
716}
717
718/// The tiled SVG mask image a [`Watermark`] renders, matching `@santi020k/lumen-react`.
719pub(crate) fn watermark_image(text: &str, gap: f64, rotate: f64) -> (String, String) {
720    let tile = if gap.is_nan() { f64::NAN } else { gap.max(1.0) };
721    let size = js_number(tile);
722    let center = js_number(tile / 2.0);
723    let rotate = js_number(rotate);
724    let escaped = escape_xml(text);
725    let svg = format!(
726        "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{size}\" height=\"{size}\" viewBox=\"0 0 {size} {size}\">\
727         <text x=\"{center}\" y=\"{center}\" dominant-baseline=\"middle\" text-anchor=\"middle\" \
728         transform=\"rotate({rotate} {center} {center})\" fill=\"black\" \
729         font-family=\"Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif\" \
730         font-size=\"16\" font-weight=\"500\" letter-spacing=\"1.6\">{escaped}</text></svg>"
731    );
732
733    (
734        format!("{size}px"),
735        format!("url(\"data:image/svg+xml,{}\")", encode_uri_component(&svg)),
736    )
737}
738
739/// Tiles rotated text over its content, behind a non-interactive overlay.
740///
741/// The overlay uses a CSS mask image; renderers without `mask-image` support, such as the current
742/// Dioxus Native engine, show the content without the tiled text.
743#[component]
744pub fn Watermark(props: WatermarkProps) -> Element {
745    let text = props.content.clone().unwrap_or_else(|| props.text.clone());
746    let (gap, image) = watermark_image(&text, props.gap, props.rotate);
747    let variables = format!("--ui-watermark-gap: {gap}; --ui-watermark-image: {image}");
748    let style = join_style([Some(variables.as_str()), props.style.as_deref()]);
749    let class = compose([Some("ui-watermark"), props.class.as_deref()]);
750
751    rsx! {
752        div { class, "data-ui-watermark": "true", style, ..props.attributes,
753            {props.children}
754            div {
755                aria_hidden: "true",
756                class: "ui-watermark__overlay",
757                "data-text": text,
758            }
759        }
760    }
761}