Warning
This is the next branch, tracking the upcoming release. For the latest stable code,
switch to the latest branch.
CSS power. Inline style simplicity.
Respond to user interaction, layout context, and inherited state. All
CSS-driven. All without leaving the style prop. By exploiting the hidden
programmability of CSS Variables, CSS Hooks delivers flexible component-owned
styling without runtime style injection or build steps.
<button style={mergeStyles( { background: "#004982", color: "#eeeff0", }, on("&:hover", { background: "#1b659c", }), on("&:active", { background: "#9f3131", }), )} > Save changes </button>
<span style={mergeStyles( { display: "none" }, on("@container (width >= 50px)", { display: "revert-layer", }), on("@container (width >= 100px)", { display: "none", }), )} > sm </span> <span style={mergeStyles( { display: "none" }, on("@container (width >= 100px)", { display: "revert-layer", }), )} > lg </span>
<div style={mergeStyles({ padding: 24 }, on("&:hover", enable("%active")))}> Hover parent <span style={mergeStyles( { color: "gray" }, on("%active", { color: "purple", }), )} > Child responds </span> </div>
React |
Preact |
Solid |
Qwik |
|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ |
Chrome |
Edge |
Safari |
Firefox |
Opera |
|---|---|---|---|---|
118+ |
118+ |
18+ |
151+ |
104+ |
Please visit css-hooks.com to get started.
Contributions are welcome. Please see the contributing guidelines for more information.
CSS Hooks is offered under the MIT license.