Replies: 15 comments 21 replies
-
This would be great! My use case is this one: The only solution I found so far is to replicate the contents of the TabPanels and not use headlessui for small screens. |
Beta Was this translation helpful? Give feedback.
-
It is technically possible, but kind of hacky. In Vue terms, you can do it by keeping an array of |
Beta Was this translation helpful? Give feedback.
-
It surprises me that the Tabs component is not controlled. I wish they had chosen to use |
Beta Was this translation helpful? Give feedback.
-
I have a current need for this feature for the same reason @ds-perfit describes |
Beta Was this translation helpful? Give feedback.
-
I don't really see much reason why the context should not be exposed for all components. This library is one of the best UI component libraries out there, but the lack of programmatic control can be frustrating at times. |
Beta Was this translation helpful? Give feedback.
-
Yeah the ability to manipulate the context without simulating a click would be great for so many use-cases. |
Beta Was this translation helpful? Give feedback.
-
pity, with chakra ui, you have something like this : |
Beta Was this translation helpful? Give feedback.
-
I'd be curious to know if there are any semantic or accessibility reasons for not having this. If not, I'd be happy to try and open a pull request with the functionality. I've got a good example of it working for react here https://github.com/NetSPI/headlessui, but it could probably be more robust. |
Beta Was this translation helpful? Give feedback.
-
One good use case is creating step-forms ! One can have next/previous buttons to programmatically change the current tab |
Beta Was this translation helpful? Give feedback.
-
I'm in the same situation here. I have links in tab 1, which needs to change the tab on click to tab 2 or 3: I can see the state changing, but the |
Beta Was this translation helpful? Give feedback.
-
As per @thiagonzalez and @marcioj, tracking the One extra note is that you should also use the <Tab.Group key={selectedTabIndex} defaultIndex={selectedTabIndex} onChange={index => setSelectedTabIndex(index)}>
... Hope Tailwind adds native support for this soon. |
Beta Was this translation helpful? Give feedback.
-
This was added, you can do this: <Tab.Group
onChange={(i: any) => setTabIndex(i)}
selectedIndex={tabIndex}
>
{children}
</Tab.Group> |
Beta Was this translation helpful? Give feedback.
-
Hey all! The Tabs component can be a controlled component now, this means that this is possible out of the box using the More info can be found here: |
Beta Was this translation helpful? Give feedback.
-
This is happening to me when trying to control selectedIndex |
Beta Was this translation helpful? Give feedback.
-
how to reset the selected tab to be nothing?(select none of the tabs) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Right now switching between tabs is only possibile with mouse and keyboard, but there are case where it would be useful to manually set the current tab in the code (for instance, a 'Next' button that should select the following tab).
I'm not sure what could be the best way to achieve it, but for what I could've seen in the code the components use the react context, and maybe the package could expose a
Tabs.TabsContext
that we can use for our purposes.Beta Was this translation helpful? Give feedback.
All reactions