Description
Provide a general summary of the feature here
Add a children
prop to <ColorSwatch>
that can take a ReactNode
or a render prop that is passed the swatch color that returns a ReactNode
.
🤔 Expected Behavior?
With a ReactNode
<ColorSwatch>
<span>Aa</span>
</ColorSwatch>
or with a render prop
<ColorSwatch>
{({ color }) => (
<span style={{ color: color.toString('css') }}>
Aa
</span>
)}
</ColorSwatch>
😯 Current Behavior
<ColorSwatch>
doesn't render any children
.
💁 Possible Solution
I think the starting point is to add children
to the render props here:
react-spectrum/packages/react-aria-components/src/ColorSwatch.tsx
Lines 18 to 25 in 93c26d8
I'm not sure what else if anything would be needed.
🔦 Context
I have a swatch that renders some text on top of the selected color in order to demonstrate text contrast, e.g.:
This is currently being done with <ColorSwatch>
by absolutely positioning the text element on top of the swatch relative to a shared parent.
💻 Examples
No response
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response