Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/datastar_py/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down