# bind-state

> A custom element that keeps state bound between elements. A data binding library that works entirely in HTML.

Latest version **1.0.0** (published 2018-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install bind-state
pnpm add bind-state
yarn add bind-state
bun add bind-state
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-08-12 |
| First published | 2018-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | matthewp |

## Links

- npm: https://www.npmjs.com/package/bind-state
- npm.io page: https://npm.io/package/bind-state

## Recent versions

- 1.0.0 (latest) — 2018-08-12

## README

# <bind-state>

A custom element that keeps state bound between elements. A data binding library that works entirely in HTML.

## Usage

In the following example 2 state properties exist, __name__ and __admin__. These properties exist within the store and can be bind to child elements using the `data-bind` attribute.

```html
<bind-state data-name="World" data-admin!>
  <input type="text"
    data-bind="name"
    data-bind-on="keyup"
    data-bind-from="value">

  <input type="checkbox" data-bind-from="checked" data-bind="admin" data-bind-on="change">

  <div>Name: <span data-bind="name"></span></div>

  <div>Is Administrator: <span data-bind="admin"></span></div>
</bind-state>
```

The `data-bind` property keeps state bound from parent store to child elements.

To make the binding two way, use events. The text input uses two new attributes:

* `data-bind-on`: Which event to bind on.
* `data-bind-from`: Which *property* on that element to bind to.

Whenever the event fires (in this case __keyup__) the `data-bind-from` property is read and set in the parent store.

## License

BSD-2-Clause

---
_Source: https://npm.io/package/bind-state · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
