Skip to content

How to use react-aria-components with styled-components? #8627

Answered by alex2
alex2 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the context. I think given the constraints I'm working with: (1) keep the existing styled components we have, and (2) use react-aria-components, the only path forward I have is using patch-package to add an elementType prop to rac's Table, Cell, Row, Column, etc. components, at which point I pass in my existing Table, TD, TR, TH, etc. styled-components, albeit partially applied so I can apply things like selected props based on the presence of data-selected etc.

e.g.

- let ElementType = useElementType('table');
+ let ElementType = props.elementType ?? 'table';

and another to add that prop to Table in the types.d.ts then the library wrapper would look something like:

export const 

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@snowystinger
Comment options

@alex2
Comment options

Answer selected by snowystinger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants