🎯
Type-safe
Full TypeScript inference for variant keys, values, and compound combinations. No casts, no `any`.
Compose component styles with multiple variants — no repetitive css() calls.
import { ev } from 'emotion-variants';
const button = ev({
base: {
padding: '10px 20px',
borderRadius: '8px',
cursor: 'pointer',
},
variants: {
size: {
small: {
fontSize: '12px',
},
large: {
fontSize: '16px',
},
},
color: {
primary: {
background: '#d36ac2',
color: 'white',
},
secondary: {
background: '#6c757d',
color: 'white',
},
},
},
defaultVariants: {
size: 'small',
color: 'primary',
},
});
type ButtonProps = NonNullable<Parameters<typeof button>[0]> & {
children: React.ReactNode;
};
function Button({ size, color, children }: ButtonProps) {
return <button css={button({ size, color })}>{children}</button>;
}