npm install @mbolli/datastar-attribute-prop
<script type="importmap">
{
"imports": {
"datastar": "https://cdn.jsdelivr.net/gh/starfederation/datastar@v1.0.0-RC.6/bundles/datastar.js"
}
}
</script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@mbolli/datastar-attribute-prop@1/dist/index.js"></script>
Interactive demo showcasing property binding with reactive signals
Uses data-prop:value to bind the value property.
Uses data-prop:disabled to control button state.
Uses data-prop without a key to set multiple properties at once.
Testing property binding with various input types.
Use an "all" checkbox to toggle multiple checkboxes at once using @setAll action. Uses event delegation with a single change handler on the parent.
ℹ️ Note: For this pattern, using data-bind with data-effect would be much simpler than data-prop. See the bulk update example in the Datastar docs for a cleaner implementation.
Setting custom properties on elements.