-
I'm working on a Implementation looks something like that: function Slot({ children, ...rest }: React.HTMLAttributes<HTMLElement>) {
return (
<>
{React.Children.map(children, (child) =>
React.isValidElement(child) ? React.cloneElement(child, rest) : child
)}
</>
);
} Example usage: export default function App() {
return (
<Slot css={{ color: "red" }}>
<p css={{ color: "blue" }}>Hello</p>
</Slot>
);
} The problem here is that the styles attached to the I know this is by design as, from Thanks a lot 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Legitimate question and unfortunately I do not know the answer. I may be playing devil's advocate here, but is this complex code truly necessary for your use case? Been doing React professionally for 5 years and have never used |
Beta Was this translation helpful? Give feedback.
-
This is mentioned in the docs: https://emotion.sh/docs/css-prop#style-precedence Note that |
Beta Was this translation helpful? Give feedback.
This is mentioned in the docs: https://emotion.sh/docs/css-prop#style-precedence
Note that
css
gets translated toclassName
within the jsx pragma - so this section of the docs describes your situation at hand.