Creating a React MUI Box and styling it like this:
<Box
id='my-box'
sx={{
'&::before': {
content: 'Yay! ',
backgroundColor: 'red'
}
}}
>Life is beautiful</Box>
However, during runtime, the CSS property content
disappears, leaving only background-color
. Manually adding content: 'Yay! '
through browser dev tools displays it correctly.
Detailed breakdown:
- Screenshot of code:
https://i.stack.imgur.com/DnikJ.png
- Incorrect display in the browser:
https://i.stack.imgur.com/YQbJT.png
- Inspecting element via dev tools - missing
content
:
https://i.stack.imgur.com/Xgz5s.png
- Manually adding
content
through dev tools:
https://i.stack.imgur.com/lX0qo.png
- Result after manually adding
content
:
https://i.stack.imgur.com/Basxy.png
How can I prevent the removal of the CSS property content
at runtime? And why does this occur initially?
Appreciate any insights. Thank you.