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

组件 segmented 的 option.value 支持 boolean 类型 #46234

Closed
zhenzhenChange opened this issue Dec 4, 2023 · 3 comments
Closed

组件 segmented 的 option.value 支持 boolean 类型 #46234

zhenzhenChange opened this issue Dec 4, 2023 · 3 comments

Comments

@zhenzhenChange
Copy link

zhenzhenChange commented Dec 4, 2023

What problem does this feature solve?

用于类似开关控制切换的效果,也类似 Tab 切换。

虽然 tab/switch 组件也可以做到,但是 segmented 样式以及 block 的效果会比较好看。

What does the proposed API look like?

https://github.com/react-component/segmented/blob/master/src/index.tsx#L9

- export type SegmentedValue = string | number;
+ export type SegmentedValue = string | number | boolean;
const Demo: React.FC = () => (
  <Segmented
    options={[
      { label: '教学空间', value: true },
      { label: '学习空间', value: false },
    ]}
  />
);
@MadCcc
Copy link
Member

MadCcc commented Dec 4, 2023

和 Select 一样支持泛型吧,默认就是 string | number 就好

@zhenzhenChange
Copy link
Author

zhenzhenChange commented Jan 5, 2024

顺带在此一提,Tabs组件是否也能够支持泛型呢?目前仅支持 string 类型,有一些场景是,使用 enum 作为 Tab 页的 key,而 enum 的值可能是 number 类型也可能是 string 类型,但此时 enum 本身将会作为一个类型使用。

@afc163
Copy link
Member

afc163 commented Mar 18, 2024

See #47091

@afc163 afc163 closed this as completed Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants