mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.97k stars 32.27k forks source link

@mui/material-pigment-css useTheme: theme has no spacing property #43803

Closed bmakan closed 3 weeks ago

bmakan commented 2 months ago

Steps to reproduce

Link to live example: CodeSandbox
(Sandbox not working, but downloading the sandbox code and running it locally works. Not sure what's going on.)

Steps:

  1. Download sandbox and unzip.
  2. bun install
  3. bun run vite
  4. open browser and check the console log for the theme - there's no spacing property in it.

Current behavior

When using the theme from import { useTheme } from "@mui/material-pigment-css";, the theme object has no spacing property. The property is present when using the import { useTheme } from "@mui/material/styles";.

Expected behavior

The theme object should have a spacing property.

Context

No response

Your environment

npx @mui/envinfo ``` System: OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish) Binaries: Node: 20.12.2 - /usr/bin/node npm: 10.5.0 - /usr/bin/npm pnpm: Not Found Browsers: Edge: Version 128.0.2739.79 (Official build) (64-bit) npmPackages: @emotion/react: 11.13.3 @emotion/styled: 11.13.0 @mui/core-downloads-tracker: 6.1.0 @mui/material: 6.1.0 => 6.1.0 @mui/material-pigment-css: 6.1.0 => 6.1.0 @mui/private-theming: 6.1.0 @mui/styled-engine: 6.1.0 @mui/system: 6.1.0 @mui/types: 7.2.16 @mui/utils: 6.1.0 @pigment-css/react: 0.0.22 => 0.0.22 @pigment-css/vite-plugin: 0.0.22 => 0.0.22 @types/react: ^18.2.65 => 18.3.7 react: ^18.2.0 => 18.3.1 react-dom: ^18.2.0 => 18.3.1 typescript: ^5.4.2 => 5.6.2 ```

Search keywords: pigmentcss theme spacing

mc-dsk commented 1 month ago

Same for shadows

siriwatknp commented 1 month ago

The goal of Pigment is to remove calling theme at runtime. Can you share what's your use case for getting the theme at runtime?

The proper way is to use the generated CSS variables:

spacing is available as --mui-spacing or theme.vars.spacing shadow is avaiable as --mui-shadows-<number> or theme.vars.shadows[number]

github-actions[bot] commented 3 weeks ago

Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information.