-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add a tab component to react-spectrum #784
Comments
Tabs and TabList component are under construction :) |
Yep though they were made a long time ago as a POC and never finished. I think at this point I would re-start the implementation or at least heavily modify it. If anyone would like to work on that, I’d be happy to provide some guidance! 😊 |
I'm interested in implementing it. :) |
@so99ynoodles awesome! Let me get back to you with some updated API specs and we can go from there. In the meantime, here’s the accessibility spec we’ll need to follow: https://w3c.github.io/aria-practices/#tabpanel |
Ok, here's the API spec we came up with. import {CollectionBase, SingleSelection} from '@react-types/shared';
import {SingleSelectListState} from '@react-stately/list';
interface TabsProps<T> extends CollectionBase<T>, SingleSelection {
/**
* Whether tabs are activated automatically on focus or manually.
* @default 'automatic'
*/
keyboardActivation?: 'automatic' | 'manual',
/**
* The orientation of the tabs.
* @default 'horizontal'
*/
orientation?: 'horizontal' | 'vertical'
}
interface TabsAria {
/** Props for the tablist container */
tabListProps: HTMLAttributes<HTMLElement>
}
declare function useTabs<T>(props: TabsProps<T>, state: SingleSelectListState<T>): TabsAria;
interface TabAria {
/** Props for the tab element */
tabProps: HTMLAttributes<HTMLElement>,
/** Props for the associated tabpanel element */
tabPanelProps: HTMLAttributes<HTMLElement>
}
interface TabAriaProps<T> {
/** Collection node for the tab. */
item: Node<T>
}
declare function useTab<T>(props: TabAriaProps, state: SingleSelectListState<T>): TabAria; There's also some spectrum specific props. I can provide those if you want to implement the Spectrum part and not just the Aria/Stately parts. Here's an example of what constructing a tab component would look like for an end user: <Tabs selectedKey="files">
<Item key="files" title="Your files">
<Files />
</Item>
<Item key="shared" title="Shared with you">
<Shared />
</Item>
</Tabs> The API follows our collection components API, using In terms of implementation, there's a few pieces:
For accessibility, the spec is listed above in my previous comment. In addition, you can see the two examples from the WAI-ARIA Authoring Practices. They cover the two I'd start by making a basic example component using the hooks and use that in the storybook/tests for now. I'm happy to also provide guidance on the Spectrum-specific parts, but they're not required if you'd like to focus on React Aria/React Stately. Another helpful thing is to start by running the That was a lot. Hopefully I covered enough to get you started, but please let me know if you have any questions! 😄 |
@devongovett
Please checkout the PR, any advice would be appreciated. |
🙋 Feature Request
Add a tab component as described in the https://www.w3.org/TR/wai-aria-practices/#tabpanel.
The text was updated successfully, but these errors were encountered: