Replies: 2 comments 2 replies
-
That is a nice concept! I tried to build something like this. The API that I felt made sense was // merg variants from multiple parents
const AccordionItem = styled(‘li’, {}).mergeVariant([Accordion])
// merge styles from parents
// it is similar to styled(Accordion) but more flexible because you can merge multiple components
const AccordionItem = styled(‘li’, {}).merge([Accordion]) |
Beta Was this translation helpful? Give feedback.
0 replies
-
I came here looking for this exact thing. With the const StyledSeparator = styled(ToolbarPrimitive.Separator, {
variants: {
orientation: {
horizontal: {
borderLeft: borderDefault,
height: "38%",
},
vertical: {
borderTop: borderDefault,
width: "38%",
},
},
},
defaultVariants: {
orientation: "!inherit",
},
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Thinking aloud here but I was wondering what thoughts are on supplying an API so consumers can specify that child components should inherit parent variant props?
This is a common requirement that currently consumers would need to piece together themselves.
I'm imagining something like:
The thinking here is that this would wrap
AccordionItem
in some Context so that when someone does<Accordion size="small" />
we would do<AccordionItem size="small" />
for them.If the first parameter passed to
variant
is a React Component then we would limit the variant definitions to the variants that exist on that component.I also like the way this could improve DX with typing. For example, if someone removed "size" from
Accordion
theAccordionItem
would error because you're telling it to style based on a parent variant that no longer exists.There is probably a better API for this but as a concept I think it would be useful. Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions