This decorator allows to easily style Preact/React (since 1.6.*) components through adding a scoped stylesheet inside that component and defined styles only get applied to it and its descendants.
Basically it allows to style preact/react like Angular or Vue does by adding a scoped stylesheet
Demo (Preact)
Getting started
install npm install stylesheet-decorator --save
usage:
- import
- define a string with raw CSS content
const style = ` span { font-size: 20px; color: lightblue; }`
- Plug it on render fn of some Preact/React component
@ { return <span>something</span>} or
That's all.
This decorator supports all CSS capabilities defined here: https://www.npmjs.com/package/scope-css
This development is related on this conversation: Twitter Link and this issue GH preact issue