API

Other libraries

Move from StyleX, Tailwind CSS, CSS Modules, styled-components, Emotion, vanilla-extract or Panda CSS to Plumeria.

Set Plumeria up first with @plumeria/init, then move styles file by file.

StyleX

The APIs keep their names and shapes. Most files change only at the import and at the call site.

StyleXPlumeria
stylex.createcss.create
{...stylex.props()}sx={[]} or css.use
stylex.defineVars + stylex.createThemecss.createTheme
stylex.defineConstscss.createStatic
stylex.keyframescss.keyframes
stylex.viewTransitionClasscss.viewTransitionClass
stylex.positionTrycss.positionTry
Before
import * as stylex from '@stylexjs/stylex';

<div {...stylex.props(styles.base, active && styles.active)} />
After
import * as css from '@plumeria/core';

<div sx={[styles.base, active && styles.active]} />

A style relayed through wrappers that the compiler cannot follow stops the build. Flatten it, or use TypedCSS.

Tailwind CSS

The Claude Code plugin converts classes, tv() and twMerge() to Plumeria styles. @plumeria/wind keeps Tailwind's design values as tokens.

Before
<button className="rounded-md bg-blue-600 px-4 text-sm text-slate-50" />
After
import * as css from '@plumeria/core';
import * as t from '@plumeria/wind';

const styles = css.create({
  button: {
    paddingInline: t.spacing[4],
    fontSize: t.text.sm,
    color: t.slate[50],
    backgroundColor: t.blue[600],
    borderRadius: t.radius.md,
  },
});

<button sx={styles.button} />

CSS Modules

Each class becomes a key, and its rules move into the key as camelCase properties.

CSS ModulesPlumeria
.button { … }button: { … } in css.create
.button:hover { … }':hover': { … } inside the key
@media (…) { .button { … } }'@media (…)': { … } inside the key
composes: basesx={[styles.base, styles.button]}
.card:hover .title { … }css.marker and css.extended
@keyframescss.keyframes
:global(…)A plain .css file
Before
.button {
  padding: 8px 16px;
  color: white;
}

.button:hover {
  opacity: 0.8;
}

@media (max-width: 768px) {
  .button {
    padding: 4px 8px;
  }
}
After
import * as css from '@plumeria/core';

const styles = css.create({
  button: {
    padding: '8px 16px',
    color: 'white',
    ':hover': {
      opacity: 0.8,
    },
    '@media (max-width: 768px)': {
      padding: '4px 8px',
    },
  },
});

<button sx={styles.button} />

Selector rules lists which selectors a key can hold.

styled-components

A styled component becomes a plain element with the sx prop. A prop that changes a value becomes a function key, and a prop that picks a style becomes a lookup.

styled-componentsPlumeria
styled.button`…`<button sx={styles.button}>
`color: ${(p) => p.color}`A function key
`${(p) => p.primary && css`…`}`sx={[styles.base, primary && styles.primary]}
`&:hover { … }`':hover': { … }
`& > span { … }`A style on the span, or css.marker
ThemeProvidercss.createTheme, with no provider
keyframescss.keyframes
createGlobalStyleA plain .css file
Before
import styled from 'styled-components';

const Button = styled.button<{ primary?: boolean; width: string }>`
  padding: 8px 16px;
  width: ${(p) => p.width};
  background: ${(p) => (p.primary ? 'blue' : 'gray')};

  &:hover {
    opacity: 0.8;
  }
`;
After
import * as css from '@plumeria/core';

const styles = css.create({
  button: {
    padding: '8px 16px',
    backgroundColor: 'gray',
    ':hover': {
      opacity: 0.8,
    },
  },
  primary: {
    backgroundColor: 'blue',
  },
  width: (width: string) => ({
    width,
  }),
});

export const Button = ({ primary, width, ...props }) => (
  <button sx={[styles.button, primary && styles.primary, styles.width(width)]} {...props} />
);

Styles are compiled at build time, so nothing is injected into the page while it renders.

Emotion

Object styles are already close to Plumeria styles: the properties stay camelCase, and '&:hover' drops the &. @emotion/styled follows the styled-components table.

EmotionPlumeria
css={{ … }}sx={styles.box}
css={css`…`}sx={styles.box}, with the rules as an object
'&:hover': { … }':hover': { … }
css={[base, active && activeStyle]} or cx()sx={[styles.base, active && styles.active]}
css={(theme) => ({ … })}css.createTheme, with no provider
keyframescss.keyframes
<Global>A plain .css file
Before
/** @jsxImportSource @emotion/react */

<div
  css={{
    padding: 16,
    color: 'white',
    '&:hover': {
      opacity: 0.8,
    },
  }}
/>
After
import * as css from '@plumeria/core';

const styles = css.create({
  box: {
    padding: 16,
    color: 'white',
    ':hover': {
      opacity: 0.8,
    },
  },
});

<div sx={styles.box} />

Remove the @jsxImportSource @emotion/react pragma, or jsxImportSource from the compiler options, once no file uses the css prop.

vanilla-extract

Styles move out of .css.ts files and next to the component that uses them.

vanilla-extractPlumeria
style({ … })A key in css.create
styleVariants, recipeA lookup, sizes[size]
'@media': { '(…)': { … } }'@media (…)': { … }
selectors: { '&:hover': { … } }':hover': { … }
selectors: { [`${parent}:hover &`]: { … } }css.marker and css.extended
createTheme, createThemeContractcss.createTheme
createVar + assignInlineVarsA function key
keyframescss.keyframes
globalStyleA plain .css file
sprinkles@plumeria/wind tokens in css.create
Before
// button.css.ts
import { recipe } from '@vanilla-extract/recipes';

export const button = recipe({
  base: { padding: 8 },
  variants: {
    size: {
      small: { fontSize: 12 },
      large: { fontSize: 18 },
    },
  },
});

// Button.tsx
<button className={button({ size })} />
After
import * as css from '@plumeria/core';

const styles = css.create({
  base: {
    padding: 8,
  },
});

const sizes = css.create({
  small: {
    fontSize: 12,
  },
  large: {
    fontSize: 18,
  },
});

<button sx={[styles.base, sizes[size]]} />

A theme no longer has a class to apply. The selector that switches it is part of the theme:

Before
// theme.css.ts
import { createTheme, createThemeContract } from '@vanilla-extract/css';

export const vars = createThemeContract({ text: null });
export const light = createTheme(vars, { text: '#111' });
export const dark = createTheme(vars, { text: '#eee' });

// App.tsx
<div className={isDark ? dark : light}>{children}</div>
After
import * as css from '@plumeria/core';

export const theme = css.createTheme('.dark', {
  text: {
    default: '#111',
    theme: '#eee',
  },
});

<div>{children}</div>

Panda CSS

The style objects keep their shape. Conditions become selector keys, and token names become values.

Panda CSSPlumeria
css({ … })A key in css.create
cva, config recipesA lookup, sizes[size]
cx()sx={[styles.base, active && styles.active]}
_hover: { … }':hover': { … }
md: { … }A '@media (…)' key from css.createStatic
tokenscss.createStatic, or @plumeria/wind
semanticTokens with _darkcss.createTheme
stack, flex and other patternsThe properties they stand for
globalCssA plain .css file
Before
import { css } from '../styled-system/css';

<button
  className={css({
    padding: '4',
    color: 'white',
    _hover: {
      opacity: 0.8,
    },
    md: {
      padding: '8',
    },
  })}
/>
After
import * as css from '@plumeria/core';
import { breakpoints } from './breakpoints';

const styles = css.create({
  button: {
    padding: 16,
    color: 'white',
    ':hover': {
      opacity: 0.8,
    },
    [breakpoints.md]: {
      padding: 32,
    },
  },
});

<button sx={styles.button} />
breakpoints.ts
import * as css from '@plumeria/core';

export const breakpoints = css.createStatic({
  md: '@media (min-width: 768px)',
});

Once no file imports from styled-system, remove panda.config.ts, the generated styled-system directory and the PostCSS plugin.

Edit on GitHub