From 1bdc78a2bf8d26ffb923133efe26f6db596189d1 Mon Sep 17 00:00:00 2001 From: travispaxton <2214573+travispaxton@users.noreply.github.com> Date: Sun, 20 Jul 2025 20:30:02 -0700 Subject: [PATCH] Update attributes.py --- src/datastar_py/attributes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/datastar_py/attributes.py b/src/datastar_py/attributes.py index 75d33ec..4b043a3 100644 --- a/src/datastar_py/attributes.py +++ b/src/datastar_py/attributes.py @@ -256,6 +256,11 @@ def show(self, expression: str) -> BaseAttr: """Show or hides an element based on whether an expression evaluates to true or false.""" return BaseAttr("show", value=expression, alias=self._alias) + def style(self, style_dict: Mapping | None = None, /, **styles: str) -> BaseAttr: + """Sets the value of inline CSS styles on an element based on an expression, and keeps them in sync.""" + styles = {**(style_dict if style_dict else {}), **styles} + return BaseAttr("style", value=_js_object(styles), alias=self._alias) + def text(self, expression: str) -> BaseAttr: """Bind the text content of an element to an expression.""" return BaseAttr("text", value=expression, alias=self._alias)