You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, tab components according to the component's props can accept only string value as a key, using non-string values causes a type error, but if we ignore this typescript error and use any other value like a number, this works.
I propose adding support for controlling the tab key type by updating the tab component types to allow numeric or custom values.
Currently, tab components according to the component's props can accept only string value as a key, using non-string values causes a type error, but if we ignore this typescript error and use any other value like a number, this works.
I propose adding support for controlling the tab key type by updating the tab component types to allow numeric or custom values.
As I understand it, the value property is essentially acting as a key in this context. The Tabs.Root has a defaultValue which essentially decides which tab to be focused from the start. Then there is a Tabs.Trigger and a corresponding Tabs.Content which need to have matching values in order for a user to navigate to the tab.
Based on this understanding, I don't think it makes a lot of sense to provide support for a numeric or general object type, as neither of those (especially a custom value) make sense as a key here. I believe numerics work because somewhere down the chain they are coerced into a string or something primitive enough to be used as a key.
Feature request
Overview
Currently, tab components according to the component's props can accept only string value as a key, using non-string values causes a type error, but if we ignore this typescript error and use any other value like a number, this works.
I propose adding support for controlling the tab key type by updating the tab component types to allow numeric or custom values.
Examples in other libraries
Who does this impact? Who is this for?
This little DX improvement might be useful for everyone so that we will have more control over the tabs component.
The text was updated successfully, but these errors were encountered: