Skip to content

Is there a way to create custom components that support the render prop? #3578

Closed Answered by diegohaz
gnapse asked this question in Questions
Discussion options

You must be logged in to vote

Yes, you can use the Role component:

function MyComponent(props) {
  return <Role.div render={props.render} />;
}

wrapElement is a lower-level prop used by internal hooks to wrap the underlying element with other components like providers and React portal. You likely will never need it unless you're building custom component hooks like useDialog, usePopover, etc. Since those hooks don't return the JSX elements, but just the props to be passed to other elements, they use this custom wrapElement prop that will be later consumed by Ariakit's own createElement or Role.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gnapse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants