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

asChild Slots #143

Open
Tracked by #154
BorisZubchenko opened this issue Dec 15, 2023 · 1 comment
Open
Tracked by #154

asChild Slots #143

BorisZubchenko opened this issue Dec 15, 2023 · 1 comment

Comments

@BorisZubchenko
Copy link

Is your feature request related to a problem? Please describe.
One of the problems with the as is that it can't be chained:

<Toolbar>
  <ToolbarButton as={Button{as={Link}}}>Share</ToolbarButton>
</Toolbar>

Describe the solution you'd like
asChild allows to have chained components. It is implemented by Radix Slot and Ark UI.

<Toolbar>
  <ToolbarButton asChild>
    <Button asChild>
      <Link>Share</Link>
    </Button>
  </ToolbarButton>
</Toolbar>

Describe alternatives you've considered
I've considered creating a HoC around classed, but:

  1. I don't know what to do with as (can be omitted though).
  2. I would like to discuss caveats here.

Additional context
I'm sure you're aware about asChild, but here some interesting points can be found:
https://www.jacobparis.com/content/react-as-child
https://sandroroth.com/blog/react-polymorphic-components/

@sannajammeh
Copy link
Owner

Thanks for the issue!

I've thought about this as well. Adding it on the roadmap for v2.

@sannajammeh sannajammeh mentioned this issue Sep 3, 2024
6 tasks
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