Macaron currently supports vite and esbuild. Install and setup the plugin for your bundler :-
vite
esbuild
In the
vite.config.js
, add the macaron plugin before other plugins
Import styled
from either @macaron-css/solid
or @macaron-css/react
and create a styled component.
Add base styles that are applied to the component by default. This can include hover states, media queries, nested selectors etc.
All styling APIs in macaron take style objects as inputs. This makes the styles type-safe and provides autocomplete via csstype
.
You can add variants by using the variants key. There is no limit to how many variants you can add.
A variant accepts the same style object as the base styles.
You can use the defaultVariants feature to set a variant by default. This variants can be overriden at the time of usage.
This component can now be used just like any regular Solid/React component with type-safe props that are derived from your variants.
Unlike vanilla-extract that restricts style declarations to .css.ts
, macaron allows you to declare styles in the same file providing true colocation.
Import styled
from either @macaron-css/solid
or @macaron-css/react
and create a styled component.
Add base styles that are applied to the component by default. This can include hover states, media queries, nested selectors etc.
All styling APIs in macaron take style objects as inputs. This makes the styles type-safe and provides autocomplete via csstype
.
You can add variants by using the variants key. There is no limit to how many variants you can add.
A variant accepts the same style object as the base styles.
You can use the defaultVariants feature to set a variant by default. This variants can be overriden at the time of usage.
This component can now be used just like any regular Solid/React component with type-safe props that are derived from your variants.
Unlike vanilla-extract that restricts style declarations to .css.ts
, macaron allows you to declare styles in the same file providing true colocation.
Other than styled
, macaron provides the following functions:-
import { styled } from '@macaron-css/solid';import { style, recipe, createTheme, createThemeContract, styleVariants, createVar, fallbackVar, assignVars, keyframs, fontFace, createContainer,} from '@macaron-css/core';