How to extract props from styled component #64
Unanswered
dominictobias
asked this question in
Q&A
Replies: 1 comment
-
To get type of props for any React component (not only when using macaron-css) you can use type StyledButtonProps = React.ComponentProps<typeof StyledButton> then, to get type of each variant (as you asked for in your question) you can use: type ColorProp = StyledButtonProps['color']
// ^? type ColorProp = "neutral" | "brand" | "accent" | undefined
type RoundedProp = StyledButtonProps['rounded']
// ^? type RoundedProp = boolean | undefined |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Taking the example:
How can we extract the props
rounded
,color
, andsize
into a type, so that we could mix in other props that our component might want? (In the case that we have a wrapping component which performs additional logic/rendering, but we still want the end user to get these props, which will will pass through)I thought typeof but I'm getting a confusing error that no types overlap:
Beta Was this translation helpful? Give feedback.
All reactions