Idea: Implement "asChild" pattern for complete component override #76
jpandersen87
started this conversation in
Ideas
Replies: 1 comment 5 replies
-
Are you suggesting this as a solution for your other discussion here? #75 …or maybe in addition to always allowing children for all applicable components? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Example: ArkUI.
It uses a factory to create basic element components that accept an
asChild
prop and forward ref. When enabled, the component will use the children (expected to be a single root element) directly, merge and pass the ref on, and attach necessary side-effect logic to it instead of the default wrapping element. This allows customizing the element used for the component (ex:section
instead ofdiv
).asChild
: https://ark-ui.com/docs/react/overview/as-child-propBeta Was this translation helpful? Give feedback.
All reactions