atomico-hooks-props

Provide bidirectional reactive access to Atomico component properties.

1.3k|44|Updated Aug 25, 2018
One-click install
npx skills add https://github.com/atomicojs/atomico --skill atomico-hooks-props
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: atomico-hooks-props
Source: https://github.com/atomicojs/atomico/tree/main/.agents/skills/atomico-hooks-props
Command: npx skills add https://github.com/atomicojs/atomico --skill atomico-hooks-props

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Components often need to both read and update their public props so internal state changes are visible to external consumers, but standard prop access is read-only. useProp solves this by providing a synchronized [value, setter] pair that writes directly to the host element property and triggers the component's observer behavior so external consumers can observe changes.

Core Features & Use Cases

  • Reactive getter/setter tuple: Returns a value and a setter that updates the actual component property.
  • Two-way data flow: Ideal for controlled inputs, toggles, and any pattern where the component must emit state changes back to consumers.
  • Type and update patterns: Supports direct values, functional updates, reset to null/undefined, and multiple types (string, number, boolean, object, Date, callbacks).
  • Safety and requirements: Enforces that the prop name is declared in the component props configuration and will throw an error otherwise; updates optionally reflect to HTML attributes when configured.
  • Compatibility: Designed for Atomico versions matching the declared compatibility constraints.

Quick Start

Create a reactive prop binding by calling useProp with a declared prop name and use the returned setter to update the host element so external consumers observe the change.

Frequently Asked Questions about atomico-hooks-props

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement two-way data binding in web components?

Two-way data binding in web components is achieved by using a reactive hook that returns a synchronized value and setter pair. This writes directly to the host element property, allowing internal state updates to be observed by external consumers.

Why are my custom element property updates not visible to consumers?

Custom element property updates remain invisible when using standard read-only prop access. A bidirectional reactive binding hook writes updates to the host element instance and triggers observer behavior, ensuring external consumers can observe the changes.

How do I create controlled form inputs with Atomico web components?

Controlled form inputs with Atomico are created by applying a bidirectional prop hook inside the component. This provides a getter and setter tuple that syncs internal state changes, like user input values, back to the host element for consumer observation.

Do I need to declare a prop in the component configuration to use reactive bindings?

Yes, you must declare the target prop in the component configuration to use reactive bindings. The hook enforces this requirement and will throw an error if the prop name is not declared, ensuring safe property synchronization.

Can reactive prop setters reflect updates to HTML attributes?

Yes, reactive prop setters can optionally reflect updates to HTML attributes when configured. This ensures that bidirectional property updates are not only synced to the custom element instance but also mirrored in the DOM for attribute-based consumers.

What types of values are supported for two-way reactive bindings?

Two-way reactive bindings support multiple value types including string, number, boolean, object, Date, and callbacks. The setter accepts direct values, functional updates, and can reset to null or undefined for flexible state management.