[yew-devel] [PATCH yew-widget-toolkit 5/7] touch: slidable action: add css classes property
Dominik Csapak
d.csapak at proxmox.com
Tue Jun 24 14:19:23 CEST 2025
With this it's possible to add more custom config to such an action,
e.g. a color scheme.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/touch/slidable/slidable_action.rs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/touch/slidable/slidable_action.rs b/src/touch/slidable/slidable_action.rs
index de37445..7ea54f5 100644
--- a/src/touch/slidable/slidable_action.rs
+++ b/src/touch/slidable/slidable_action.rs
@@ -26,6 +26,10 @@ pub struct SlidableAction {
#[prop_or_default]
pub icon_class: Option<Classes>,
+ #[prop_or_default]
+ /// Optional additional CSS classes
+ pub class: Classes,
+
/// Click callback.
///
/// Emited when the user clicks on the entry.
@@ -56,6 +60,17 @@ impl SlidableAction {
self.on_activate = cb.into_event_callback();
self
}
+
+ /// Builder style method to add a CSS class.
+ pub fn class(mut self, class: impl Into<Classes>) -> Self {
+ self.add_class(class);
+ self
+ }
+
+ /// Method to add a CSS class.
+ pub fn add_class(&mut self, class: impl Into<Classes>) {
+ self.class.push(class.into());
+ }
}
pub enum Msg {
@@ -125,6 +140,7 @@ impl Component for PwtSlidableAction {
Container::new()
.class("pwt-slidable-action")
+ .class(props.class.clone())
.with_optional_child(icon)
.with_child(props.label.clone())
.onclick(onclick)
--
2.39.5
More information about the yew-devel
mailing list