A lightweight, pragmatic solution for adding reactive data binding to your existing HTML. No build tools required.
Just HTML + JavaScript. No JSX, no virtual DOM, no complex build pipelines. It just works.
Extremely small footprint (~15KB) and high performance. Updates only what needs to change.
Automatic UI updates when data changes using modern JavaScript Proxies. Like Vue 3, but simpler.
Use simple data-bind-* attributes to connect your UI to your data. Supports text, events, loops, conditionals,
and two-way binding out of the box.
dataBind.js is a drop-in JavaScript library that requires no build tools or compilation. Simply include the script tag and start using declarative data bindings in your HTML. Click on any binding below to see examples and learn how to use them.
Display text content from your viewModel. Supports deep property paths.
Two-way data binding for form inputs. Automatically syncs input values with your viewModel.
Handle click events. The handler receives the event and element as parameters.
Handle change events on form inputs. Receives event, element, newValue, and oldValue.
Render lists from arrays. Use $index for the current index and $root to access the root viewModel.
Conditionally render elements. Removes element from DOM when condition is false.
Toggle element visibility with CSS. Element stays in DOM but is hidden when condition is false.
Switch statement for multiple conditions. Only the matching case will be rendered.
Dynamically add/remove CSS classes based on conditions or bind a string of class names.
Dynamically set element attributes from a function or object in your viewModel.
Render templates with data from your viewModel.
Handle form submit events.
Handle blur events when an element loses focus.
Handle focus events when an element receives focus.
Handle double-click events.
Handle hover in and out events.
Handle input events as user types (fires on every keystroke).
Identifier attribute for selecting component elements. Use it to target specific parts of your page for dataBind initialization.