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

styleOverrides not being applied #95

Closed
oe-josh-martin opened this issue May 22, 2024 · 2 comments
Closed

styleOverrides not being applied #95

oe-josh-martin opened this issue May 22, 2024 · 2 comments
Assignees
Labels
package: system Specific to @mui/system

Comments

@oe-josh-martin
Copy link

oe-josh-martin commented May 22, 2024

Steps to reproduce

I'm using PigmentCSS for a design system, it's working fine for me to grab the tokens from the theme.tokens, but it's not applying any of the styleOverrides when I pass them to the name / slot.

Package

Accordion.styled.ts

export const Content = styled('div', { name: 'Accordion', slot: 'Content' })(
    ({ theme }) => ({
        padding: `${theme.tokens.spacing.sm} ${theme.tokens.spacing.lg} ${theme.tokens.spacing.sm}`,
    })
);

App
next.config.js

module.exports = withPigment(
    {
        ...
        transpilePackages: ['@...'],
    },
    {
        theme: {
            tokens: {
                padding: ...
            },
            styleOverrides: {
                Accordion: {
                    Content: {
                        backgroundColor: 'red',
                    },
                },
            },
        },
        transformLibraries: ['@...'],
    }
)

Current behavior

Padding styles are correctly applied, but no styleOverrides are carried through. I thought maybe it would only override styles that had been applied, but even if I pass something like the below, still nothing is applied.

styleOverrides: {
    Accordion: {
        Content: {
            padding: 0,
        },
    },
},
Screenshot 2024-05-22 at 11 39 30

Search keywords: style overrides

@oe-josh-martin oe-josh-martin added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 22, 2024
@zannager zannager added the package: system Specific to @mui/system label May 24, 2024
@brijeshb42
Copy link
Contributor

styleOverrides should be nested inside components key

module.exports = withPigment(
    {
        ...
        transpilePackages: ['@...'],
    },
    {
        theme: {
            ...
            components: {
              Accordion: {
                styleOverrides: {
                  Content: {
                    // your css
                  }
                }
              }
            }
        },
        transformLibraries: ['@...'],
    }
)

Feel free to re-open if you face any issues.

@oe-josh-martin
Copy link
Author

Perfect, thanks @brijeshb42. Perhaps worth updating the docs to clarify as they suggest doing it a different way 👍

@zannager zannager removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: system Specific to @mui/system
Projects
None yet
Development

No branches or pull requests

3 participants