italic() is IMHO very missleading ... On Tuesday, 04/07/2026, 15:09, Dominik Csapak wrote: >From : Dominik Csapak Sent on : Tuesday, 04/07/2026, 15:09 To : yew-devel@lists.proxmox.com Subject : [PATCH yew-widget-toolkit v3] widget: add 'div', 'span' and 'italic' helper functions these are just a simple wrapper around the `Container` widget, but it's very useful in situations where bare strings are used in a flex layout, since e.g. a `Row` with multiple children that are all strings won't get a proper flex layout (since they're not elements) So instead of writing ``` Row::new()    .with_child(Container::new().with_child("Text1"))    .with_child(Container::new().with_child("Text2")) ``` one can now write ``` Row::new()    .with_child(div("Text1"))    .with_child(div("Text2")) ``` which is much shorter and more readable. In addition to the `div` helper also add a `span` and `italic` helper, which correspond to the `` and `` tag respectively. We have to use the ContainerBuilder trait in the individual functions, since a global import in this file here would conflict with the `Properties` derive macro. To expose these functions, simply make the 'container' module public. Signed-off-by: Dominik Csapak --- src/widget/container.rs [http://container.rs/] | 24 ++++++++++++++++++++++++ src/widget/mod.rs [http://mod.rs/]       |  2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/widget/container.rs [http://container.rs/] b/src/widget/container.rs [http://container.rs/] index 23d637b..0f5e9b5 100644 --- a/src/widget/container.rs [http://container.rs/] +++ b/src/widget/container.rs [http://container.rs/] @@ -57,3 +57,27 @@ impl IntoVTag for Container {         )     } } + +/// Helper function to create a `
` element with a single child. +/// +/// It's the same as `Container::new().with_child(comp)` +pub fn div(comp: impl Into) -> Container { +    use crate::props::ContainerBuilder; +    Container::new().with_child(comp) +} + +/// Helper function to create a `` element with a single child. +/// +/// It's the same as `Container::from_tag("span").with_child(comp)` +pub fn span(comp: impl Into) -> Container { +    use crate::props::ContainerBuilder; +    Container::from_tag("span").with_child(comp) +} + +/// Helper function to create an `` element with a single child. +/// +/// It's the same as `Container::from_tag("i").with_child(comp)` +pub fn italic(comp: impl Into) -> Container { +    use crate::props::ContainerBuilder; +    Container::from_tag("i").with_child(comp) +} diff --git a/src/widget/mod.rs [http://mod.rs/] b/src/widget/mod.rs [http://mod.rs/] index 0df2cbf..ff3234a 100644 --- a/src/widget/mod.rs [http://mod.rs/] +++ b/src/widget/mod.rs [http://mod.rs/] @@ -31,7 +31,7 @@ pub use catalog_loader::PwtCatalogLoader; mod column; pub use column::Column; -mod container; +pub mod container; pub use container::Container; mod confirm_dialog; -- 2.47.3