This page demonstrates all the Datastar attributes available in gomponents-datastar.
Signals are reactive state variables. Click the buttons to modify them.
clicks
The data-text attribute binds text content to an expression.
Hello, !
The data-bind attribute creates two-way data binding between signals and form elements.
Value:
Selected:
Message length:
The data-show attribute shows or hides elements based on an expression.
Visible:
The data-class attribute adds or removes classes based on expressions.
The data-attr attribute sets attribute values based on expressions.
Clicks: /10
Button disabled:
The data-style attribute sets inline styles based on expressions.
Counter:
The data-computed attribute creates read-only signals based on expressions.
Total: $
The data-effect attribute executes expressions when signals change.
Open the browser console and change the counter to see the effect in action.
The data-init attribute runs expressions when elements are loaded.
Check the browser console to see when this section initialized.
The data-on attribute attaches event listeners to elements.
Clicks:
Hovering:
Debounced value:
The data-on-interval attribute runs expressions at regular intervals.
Seconds elapsed:
The data-on-intersect attribute runs expressions when elements enter the viewport.
Scroll down to see the intersection observer in action...
Intersected:
The data-ref attribute creates signals that reference DOM elements.
The data-preserve-attr attribute preserves attribute values during DOM morphing.
This content is inside a details element. The 'open' attribute is preserved during DOM updates.
The data-ignore attribute tells Datastar to ignore an element and its descendants.
The data-ignore-morph attribute prevents elements from being morphed during DOM updates.
The data-on-signal-patch attribute runs expressions when signals are patched.
Open the console and change the counter to see signal patch events.
Built with gomponents and Datastar