react-any-attr

npm versionbundle sizelicense

React won't let you set an arbitrary HTML attribute it doesn't recognize - it either drops it or warns about it.<AnyAttribute> (and the useAnyAttributes hook) wraps an element and applies whatever attributes you give it directly to the DOM node, reactively: change the attributes prop on a later render and the DOM updates to match, including removing keys that disappeared.

Three small helpers - asObject, asString, asBoolean - control exactly how a value gets written: as a real HTML-idiomatic boolean attribute (present/absent, no "true"/"false" strings), as a plain string visible in dev tools, or passed through untouched for anything that isn't meant to show up in the markup at all.

Source ยทnpm

npm i react-any-attr

Live playground