Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export StyledVariants #389

Open
1 task done
francescovenica opened this issue Mar 14, 2025 · 0 comments
Open
1 task done

Export StyledVariants #389

francescovenica opened this issue Mar 14, 2025 · 0 comments
Assignees
Labels
customization: css Design CSS customizability package: system Specific to @mui/system status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@francescovenica
Copy link

francescovenica commented Mar 14, 2025

Search keywords

variants

Latest version

  • I have tested the latest version

Summary

Would be possible to export the StyledVariants?

Examples

export const SharedCss: StyledVariants<MyProps> = ({ theme }: ThemeArgs) => ({
  variants: [
    {
      props: { variant: "variant" },
      style: { color: "black" },
    },
  ],
});

export const StyledBtn = styled("button")<ButtonProps>()(SharedCss);
export const StyledLink = styled(Link)<ButtonProps>()(SharedCss);

Motivation

It would be good to be able to create a function like SharedCss and share a piece of css with the theme and the variants working in typescript, another reason would be to split the variants in smaller chunk:

const variantSizes = [...]
const variantType = [...]

export const StyledLink = styled(Link)<ButtonProps>()(() => ({
   variants: [...variantSizes, ...variantType]
}));
@francescovenica francescovenica added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 14, 2025
@zannager zannager added package: system Specific to @mui/system customization: css Design CSS customizability labels Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: css Design CSS customizability package: system Specific to @mui/system status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants