Open andrew-pledge-io opened 4 weeks ago
Could you use the css property content
with a string?
We'd need to enforce some roles if we allowed children, they'd all need to be presentational.
I'm currently using an absolutely positioned sibling as a workaround.
I'm sure a pseudo element could be made to work but it's a little more difficult to style given the color is coming from JavaScript, especially in Tailwind.
Provide a general summary of the feature here
Add a
children
prop to<ColorSwatch>
that can take aReactNode
or a render prop that is passed the swatch color that returns aReactNode
.π€ Expected Behavior?
With a ReactNode
or with a render prop
π― Current Behavior
<ColorSwatch>
doesn't render anychildren
.π Possible Solution
I think the starting point is to add
children
to the render props here: https://github.com/adobe/react-spectrum/blob/93c26d8bd2dfe48a815f08c58925a977b94d6fdd/packages/react-aria-components/src/ColorSwatch.tsx#L18-L25I'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