Multiple CSS properties (using yield)
Another way is to generate multiple CSS properties is to use JS generator functions.
Here is how it would look:
import { defineConfig, presetWind3 } from "unocss";
export default defineConfig({ presets: [presetWind3()], rules: [ [ /^fancy-(.*)$/, function* ([, c]) { yield { color: `${c}` }; yield { "text-decoration": `underline ${c}` }; }, ], ],});
The yield syntax is powerful and allows us to use symbols to add things like multi selector rules which we’ll cover in the next lesson.
Files
Preparing Environment
- Installing dependencies
- Starting http server