Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slottable support? #14

Closed
ceopaludetto opened this issue Jun 29, 2024 · 2 comments
Closed

Slottable support? #14

ceopaludetto opened this issue Jun 29, 2024 · 2 comments

Comments

@ceopaludetto
Copy link

In radix there's a Slottable component to be used with Slot which allow sibling components inside the slot (https://www.radix-ui.com/primitives/docs/utilities/slot#basic-example). It would be awesome to use in RN as well

@ceopaludetto
Copy link
Author

ceopaludetto commented Jun 30, 2024

When I said Slottable I mean:
image

In a normal slot like below, if you use asChild prop, you are not allowed to have inner content (eg an Icon):

export function Component({ asChild, children }) {
  const As = asChild ? Slot : "button";
  
  return <As><SomeIcon />{children}</As>
}

This will cause a children array which is not allowed (since the Slot relies in the cloneElement function). Then radix introduced Slottable, which is basically a simple fragment wrapper which is used to do something like this:

export function Component({ asChild, children }) {
  const As = asChild ? Slot : "button";
  
  return <As><SomeIcon /><Slottable>{children}</Slottable></As>
}

Now you can use the component normally, because if you use asChild then the Slottable children will be cloned and not the Slot children itself

@mrzachnugent
Copy link
Collaborator

Unfortunately, we will not be adding this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants