npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yacobolo/datastar-prop

v1.0.2

Published

A Datastar plugin that provides property binding to sync element properties with reactive signals, with deep reactivity and Lit component support

Readme

@yacobolo/datastar-prop

npm version Release GitHub Pages License: MIT

A Datastar plugin that provides property binding to sync element properties with reactive signals.

Features

  • Property binding - Bind signals directly to DOM element properties (not attributes)
  • Deep reactivity - Automatically subscribes to nested signal changes
  • Lit component support - Calls requestUpdate() for proper Lit lifecycle integration
  • Single & multi-property syntax - Bind one property or multiple at once
  • Kebab-case conversion - data-prop:color-config becomes colorConfig
  • Tiny bundle - ~800 bytes minified

Why This Plugin?

Datastar includes a built-in data-attr plugin for setting HTML attributes, but HTML attributes and DOM properties are not the same thing.

While data-attr works great for HTML attributes (like class, id, href), many DOM interactions require setting properties directly:

  • Input value property (vs. the value attribute which only sets initial value)
  • Checkbox checked property
  • Element disabled property for real-time form control
  • Complex objects/arrays to web components (where JSON.stringify won't work)

This plugin fills that gap with added benefits:

  • Deep reactivity ensures nested signal changes trigger updates
  • Lit support handles Datastar's reactive proxies correctly

Installation

npm install @yacobolo/datastar-prop

Demo

View Interactive Demo →

Usage

This plugin requires an import map to resolve the datastar module:

<script type="importmap">
{
  "imports": {
    "datastar": "https://cdn.jsdelivr.net/gh/starfederation/[email protected]/bundles/datastar.js"
  }
}
</script>
<script type="module">
  // Import the plugin - it will auto-register with Datastar
  import 'https://cdn.jsdelivr.net/npm/@yacobolo/datastar-prop@1/dist/index.js';
</script>

Note: Using @1 will automatically use the latest v1.x.x version.

API

Single Property Binding

Bind a single property using the :property-name suffix:

<input data-prop:value="$mySignal" />
<input data-prop:checked="$isChecked" />
<button data-prop:disabled="$isDisabled">Submit</button>

Property names are converted from kebab-case to camelCase:

  • data-prop:color-configcolorConfig
  • data-prop:my-propertymyProperty

Multiple Property Binding

Bind multiple properties at once using an object:

<input data-prop="{ value: $inputValue, disabled: $isDisabled }" />

Complex Objects (Web Components)

Pass complex objects to web components - the main use case for this plugin:

<div data-signals="{ 
  colorConfig: { r: 255, g: 100, b: 50, name: 'Orange' },
  items: ['Apple', 'Banana', 'Cherry']
}">
  
  <!-- Pass nested object to Lit component -->
  <color-picker data-prop:color-config="$colorConfig"></color-picker>
  
  <!-- Pass array to list component -->
  <item-list data-prop:items="$items"></item-list>
  
</div>

The plugin's deep reactivity ensures that changes to nested properties (like $colorConfig.r = 128) will trigger updates.

Deep Reactivity

Unlike simple property binding, this plugin recursively reads all nested properties of your signals. This causes Datastar's effect system to subscribe to changes at any depth:

<div data-signals="{ config: { nested: { deep: 'value' } } }">
  <!-- Changes to $config.nested.deep will trigger updates -->
  <my-component data-prop:config="$config"></my-component>
</div>

Lit Component Support

When working with Lit components, Datastar's reactive proxies maintain the same object reference when internal values change. This would normally prevent Lit from detecting changes.

This plugin automatically calls requestUpdate(propName) on Lit elements, ensuring proper lifecycle updates:

// Your Lit component
@customElement('my-component')
class MyComponent extends LitElement {
  @property({ type: Object })
  config = {};
  
  updated(changedProperties) {
    // This fires correctly when $config changes internally
    if (changedProperties.has('config')) {
      console.log('Config updated:', this.config);
    }
  }
}

Manual Registration

If you need to register the plugin manually (e.g., for custom bundling):

import propPlugin from '@yacobolo/datastar-prop';
import { attribute, effect } from 'datastar';

// Register manually
attribute(propPlugin(effect));

Testing

task test

Development

This project uses Task for task automation.

# Show available tasks
task

# Build and run development server
task dev

# Production build
task build

# Run tests
task test

Releases

Releases are managed manually using Task commands:

# Bump patch version and publish (1.0.1 → 1.0.2)
task release:patch

# Bump minor version and publish (1.0.1 → 1.1.0)
task release:minor

# Bump major version and publish (1.0.1 → 2.0.0)
task release:major

Each release command will:

  1. Build the project
  2. Run tests
  3. Bump the version
  4. Publish to npm
  5. Push tags to GitHub

License

MIT