As I understand MUI 5 uses Emotion under the hood for styling, Emotion has this nice helper function css that looks like returns a string - a class name that you could use as a value for className or any other property.
import { css, cx } from '@emotion/css'
render(
<div
className={css`
padding: 32px;
background-color: hotpink;
font-size: 24px;
`}
>
Text
</div>
)
I looked everywhere but could not find an analog available in MUI. There is css function in system and styled-engine but it does not seem to do the same, it returns SerializedStyles.
The use case I am looking to use it for is following:
I have a component that let's you to pass class-names (strings) for different parts of that component enabling you to change the component's styling. It seems like this css function (as shown in Emotion docs) could help me with this.
e.g.:
const headerStyle = css`
color: blue;
border-bottom: 1px solid red;
`;
<Component
headerClassName={headerStyle}
footerClassName={css`
color: gray;
font-size: 2rem;
`}
/>
I guess I could solve it with makeStyles() but it is "legacy" not and the syntax shown on the screenshot above is more compelling to me.