Gem 一覧へ戻る
react-component/segmented(新しいタブで開きます)
主要言語: TypeScript
🧩 React segmented control for switching between compact options.
- star 数
- 16
- watcher 数
- 5
- fork 数
- 31
- issue 数
- 10
- 最終更新
- 2026/09/07
主要言語: TypeScript
🧩 React segmented control for switching between compact options.
English | 简体中文
classNames and styles slots for item and label customization.npm install @rc-component/segmented
import Segmented from '@rc-component/segmented'; import '@rc-component/segmented/assets/index.css'; export default () => ( <Segmented options={['Daily', 'Weekly', 'Monthly']} defaultValue="Weekly" onChange={(value) => { console.log(value); }} /> );
Online preview: https://segmented.react-component.vercel.app/
Run the local dumi site:
npm install npm start
Then open http://localhost:8000.
| Name | Type | Default | Description |
|---|---|---|---|
className |
string | '' |
Additional class name. |
classNames |
Partial<Record<'item' | 'label', string>> | - | Semantic class names for internal slots. |
defaultValue |
string | number | first option value | Initial selected value. |
direction |
'ltr' | 'rtl' |
- | Layout direction. |
disabled |
boolean | false | Disable all options. |
itemRender |
(node: ReactNode, info: { item: SegmentedLabeledOption }) => ReactNode |
identity | Custom option item renderer. |
motionName |
string | 'thumb-motion' |
Motion class name for the active thumb. |
name |
string | - | Radio group name. |
onChange |
(value: string | number) => void |
- | Triggered when the selected value changes. |
options |
Array<string | number | SegmentedLabeledOption> | - | Available options. Required. |
prefixCls |
string | 'rc-segmented' |
Prefix class name. |
style |
React.CSSProperties | - | Root style. |
styles |
Partial<Record<'item' | 'label', React.CSSProperties>> | - | Semantic styles for internal slots. |
value |
string | number | - | Controlled selected value. |
vertical |
boolean | false | Render options vertically. |
Additional valid div props are passed to the root element.
| Name | Type | Default | Description |
|---|---|---|---|
className |
string | - | Option class name. |
disabled |
boolean | false | Disable this option. |
label |
ReactNode | - | Displayed option content. |
title |
string | derived from label | Native title for the label. |
value |
string | number | - | Option value. |
npm install
npm start
npm test
npm run tsc
npm run compile
npm run buildThe dumi site runs at http://localhost:8000 by default.
npm run prepublishOnly
The release flow is handled by @rc-component/np through the rc-np command after the package build.
@rc-component/segmented is released under the MIT license.