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

[Tabs] Numeric/custom value support #3113

Open
anatoliilitvinovr opened this issue Sep 10, 2024 · 1 comment
Open

[Tabs] Numeric/custom value support #3113

anatoliilitvinovr opened this issue Sep 10, 2024 · 1 comment

Comments

@anatoliilitvinovr
Copy link

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.

@ericschmar
Copy link

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

* [MUI](https://mui.com/material-ui/react-tabs)

* [React-Bootstrap](https://react-bootstrap.netlify.app/docs/components/tabs)

* [NextUI](https://nextui.org/docs/components/tabs)

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.

@anatoliilitvinovr If I understand this correctly, you'd like to use a string, numeric, or some other custom value as for the prop named value according to these docs: https://www.radix-ui.com/primitives/docs/components/tabs.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants