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

[system] Expose spacing unit as a CSS variable #37911

Closed
acomanescu opened this issue Jul 11, 2023 · 1 comment · Fixed by #40224
Closed

[system] Expose spacing unit as a CSS variable #37911

acomanescu opened this issue Jul 11, 2023 · 1 comment · Fixed by #40224
Assignees
Labels
customization: theme Centered around the theming features enhancement This is not a bug, nor a new feature package: system Specific to @mui/system

Comments

@acomanescu
Copy link

acomanescu commented Jul 11, 2023

Summary 💡

I know I can access it using the theme as JS object, but I need it as a CSS variable for RSC styles.

Examples 🌈

:root {
  --joy-spacing: 8px;
}

It must include the PX to be able to use calc css fn.

Motivation 🔦

I've found some interesting use cases where I need to use the theme spacing unit as a CSS variable.

@acomanescu acomanescu added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 11, 2023
@zannager zannager added package: system Specific to @mui/system package: joy-ui Specific to @mui/joy customization: theme Centered around the theming features labels Jul 11, 2023
@mj12albert mj12albert added enhancement This is not a bug, nor a new feature and removed package: system Specific to @mui/system status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 13, 2023
@siriwatknp siriwatknp added package: system Specific to @mui/system and removed package: joy-ui Specific to @mui/joy labels Jul 17, 2023
@siriwatknp
Copy link
Member

siriwatknp commented Jul 17, 2023

Thanks for reporting the issue! I think we have to find a way for non-breaking change.

I am thinking that the theme.spacing(…) should produce calc(…), that's it.

theme.spacing(2) // calc(var(--joy-spacing, 8px) * 2)
theme.spacing(1, 2) // calc(var(--joy-spacing, 8px) * 1) calc(var(--joy-spacing, 8px) * 2)

However, I don't think everyone would agree with me so we have to provide some opt-in function I guess.

As a workaround, you can replace the theme.spacing with your own implementation.

@danilo-leal danilo-leal changed the title [Joy][Theme] Expose spacing unit as a CSS variable [system] Expose spacing unit as a CSS variable Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features enhancement This is not a bug, nor a new feature package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants