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

support as property in headless components #235

Closed
travis opened this issue Jan 6, 2023 · 0 comments · Fixed by #236, #372, #371, #375 or #377
Closed

support as property in headless components #235

travis opened this issue Jan 6, 2023 · 0 comments · Fixed by #236, #372, #371, #375 or #377
Assignees
Milestone

Comments

@travis
Copy link
Member

travis commented Jan 6, 2023

Similar toolkits like HeadlessUI (https://github.com/tailwindlabs/headlessui) and Plate (https://github.com/udecode/plate) support passing an as property to the components they provide that changes the root markup element of the component. I'm already finding a need for this in the work I'm doing on #224 so I'd like to dig in to supporting this.

After digging around in HeadlessUI and Plate I think it might make the most sense to use https://ariakit.org/ for this as they already have much of the functionality implemented there. We'll probably also get a host of other useful a11y features from doing this, which seems like a major win to me.

@travis travis self-assigned this Jan 6, 2023
@travis travis added this to the w3up phase 2 milestone Jan 6, 2023
@travis travis linked a pull request Jan 12, 2023 that will close this issue
travis added a commit that referenced this issue Jan 13, 2023
follow the pattern set by HeadlessUI and others of supporting the very
useful "as" property in the uploader component. this:

1. lets users override default tag types (eg, changing a `button` to an
`a` tag)
2. lets users provide custom components to be used as the root element
of our headless components
3. lets users elide a root tag entirely by passing `Fragment` to `as`

See
https://headlessui.com/react/menu#rendering-a-different-element-for-a-component
for more documentation on how this is commonly used

This introduces a new dependency on ariakit-react-utils
(https://ariakit.org/) to avoid reproducing the intricate puzzle of
types in the `createComponent` and `createElement` functions from that
library. I suspect other utilities will be useful as we improve the
accessibility defaults of this library so I think this dependency is
worth adding, but we could copy/paste the specific code we need with
proper attribution if we want to avoid pulling in the whole library.

resolves #235

Co-authored-by: Alan Shaw <[email protected]>
Co-authored-by: Yusef Napora <[email protected]>
Co-authored-by: Nathan Vander Wilt <[email protected]>
travis added a commit that referenced this issue Feb 3, 2023
🤖 I have created a release *beep* *boop*
---


##
[2.1.0](react-keyring-v2.0.1...react-keyring-v2.1.0)
(2023-02-03)


### Features

* "Headless" UI components
([#136](#136))
([46583e0](46583e0))
* delegate access to spaces
([#293](#293))
([441d757](441d757))
* support `as` prop in uploader component
([#236](#236))
([c802e99](c802e99)),
closes [#235](#235)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Travis Vachon <[email protected]>
Co-authored-by: Travis Vachon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment