Plumeria logoPlumeria

variants

Define a variant that can receive arguments dynamically.

Example

import * as css from "@plumeria";

const getButtonStyle = css.variants({
  variant: {
    gradient: styles.gradient,
    metallic: styles.metallic,
  },
  size: {
    small: styles.small,
    medium: styles.medium,
    large: styles.large,
  },
});

interface Props {
  children: ReactNode;
  variant: 'gradient' | 'metallic';
  href: string;
}

export const ButtonLink = ({ children, variant, href }: Props) => {
  return (
    <Link href={href} className={css.props(getButtonStyle({ variant, size: 'medium' }))}>
      {children}
    </Link>
  );
};
// call Components
<Link href={"/docs"} variant="metallic">{...}</Link>

Good to know

After being expanded to className, it is safely deleted.

On this page