Support passing theme into css()
(or its wrapper) from '@emotion/react'
#44387
Labels
customization: css
Design CSS customizability
new feature
New feature or request
package: system
Specific to @mui/system
Summary
According to the documentation (one, two, three), passing the
theme
is currently only supported when usingstyled()
from'@mui/material/styles'
(which, to my understanding, is a wrapper overstyled()
from'@emotion/styled'
). However, there's no similar wrapper forcss()
that would allow passing the theme as well. Adding this wrapper would simplify code in some cases, removing the need to create additional wrappers around React components.Examples
Note: in the following example
sx={{m: 1}}
would suffice, but imagine you need the classname orSerializedStyles
hereCurrent
Proposed
Motivation
Using
css()
is sometimes preferred because it eliminates the need for an additional identifier (e.g.,StyledBox
) in the search scope. The inability to pass thetheme
limits its usage to cases where thetheme
is not needed, which can be surprising since libraries like tss-react, JSS, and Pigment allow passing thetheme
to similar utilities. Supporting this functionality for Emotion'scss()
would close this gap.Search keywords: css, emotion, theme
The text was updated successfully, but these errors were encountered: