Open svidskiy opened 1 month ago
Hey @svidskiy, if I understand correctly, you're using TabContext
from @mui/lab
to retrieve the current tab (value
).
The plan for a future major version of Material UI is to adopt Base UI's Tab component. That'd probably imply some changes in the Tabs component API. We probably won't expose any context once we adopt Base UI: I consider these contexts implementation details and as such, they shouldn't be exposed.
If we decide to keep exposing such context in the future, we should do it in every other component under similar circumstances (e.g. Accordion
).
For now, I recommend you to use a custom context to handle this if you need to: https://codesandbox.io/p/sandbox/bold-aryabhata-rwrsjk?file=/src/Demo.tsx:20,21
cc @DiegoAndai in case you want to chime in.
If this gets enough interest, we could discuss implementing it, but I agree with @aarongarciah that using a custom context is the best approach currently. If you want to see this implemented, please add a 👍🏼 reaction to the issue's description.
Summary
Currently, MUI only allows retrieving the value of a tab through context, but it does not support the ability to modify or manage tabs dynamically via context. It would be beneficial to extend the functionality by adding the ability to modify the current tab value and other tab parameters through a context API.
Examples
An example implementation could reference the Material Design specification, which outlines the possibility of dynamic component management via contexts. This would enable the creation of more flexible and interactive interfaces where tabs can be changed based on different conditions in the application.
Search keywords: tabs, context