[RFC PATCH yew-widget-toolkit 2/3] macros: widget: impl WidgetStyleBuilder for svgs

Dominik Csapak
2026-03-20T16:08:35Z

svg elements such as Circle, Group, etc. have a style property that can
be set, so implement this for them.

padding/margin/border can be set on such elements too but have no
effect, so don't implement them for svg elements.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
pwt-macros/src/widget.rs | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/pwt-macros/src/widget.rs b/pwt-macros/src/widget.rs
index 08f2c1c..7e9ade2 100644
--- a/pwt-macros/src/widget.rs
+++ b/pwt-macros/src/widget.rs
@@ -218,24 +218,27 @@ fn derive_widget(setup: &WidgetSetup, widget: DeriveInput) -> Result<proc_macro2
}
});

- if !setup.is_svg {
- output.extend(quote!{
- impl #impl_generics #pwt::props::AsClassesMut for #ident #ty_generics #where_clause {
- fn as_classes_mut(&mut self) -> &mut ::yew::Classes {
- &mut self.std_props.class
- }
+ output.extend(quote! {
+ impl #impl_generics #pwt::props::AsClassesMut for #ident #ty_generics #where_clause {
+ fn as_classes_mut(&mut self) -> &mut ::yew::Classes {
+ &mut self.std_props.class
}
+ }

- impl #impl_generics #pwt::props::AsCssStylesMut for #ident #ty_generics #where_clause {
- fn as_css_styles_mut(&mut self) -> &mut #pwt::props::CssStyles {
- &mut self.std_props.styles
- }
+ impl #impl_generics #pwt::props::AsCssStylesMut for #ident #ty_generics #where_clause {
+ fn as_css_styles_mut(&mut self) -> &mut #pwt::props::CssStyles {
+ &mut self.std_props.styles
}
+ }
+
+ impl #impl_generics #pwt::props::WidgetStyleBuilder for #ident #ty_generics #where_clause {}
+ });

+ if !setup.is_svg {
+ output.extend(quote! {
impl #impl_generics #pwt::props::CssMarginBuilder for #ident #ty_generics #where_clause {}
impl #impl_generics #pwt::props::CssPaddingBuilder for #ident #ty_generics #where_clause {}
impl #impl_generics #pwt::props::CssBorderBuilder for #ident #ty_generics #where_clause {}
- impl #impl_generics #pwt::props::WidgetStyleBuilder for #ident #ty_generics #where_clause {}
});
}

--
2.47.3