# @rc-component/segmented

> React segmented controls used in ant.design

Latest version **1.4.0** (published 2026-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rc-component/segmented
pnpm add @rc-component/segmented
yarn add @rc-component/segmented
bun add @rc-component/segmented
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2026-08-18 |
| First published | 2025-01-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 49.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Maintainers | zombiej, afc163, madccc, peachscript, chenshuai2144 |
| Keywords | react, react-component, react-segmented, react-segmented-controls, segmented controls, antd, ant-design |

## Links

- npm: https://www.npmjs.com/package/@rc-component/segmented
- Repository: https://github.com/react-component/segmented
- Homepage: https://react-component.github.io/segmented
- Issues: https://github.com/react-component/segmented/issues
- npm.io page: https://npm.io/package/@rc-component/segmented

## Dependencies (4)

- [clsx](https://npm.io/package/clsx.md) ^2.1.1
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^8.0.0
- [@rc-component/util](https://npm.io/package/@rc-component/util.md) ^1.11.1
- [@rc-component/motion](https://npm.io/package/@rc-component/motion.md) ^1.1.4

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.4.0 (latest) — 2026-08-18
- 1.3.0 — 2025-12-18
- 1.2.3 — 2025-11-25
- 1.2.2 — 2025-09-10
- 1.2.1 — 2025-07-03
- 1.2.0 — 2025-07-02
- 1.1.0 — 2025-01-24
- 1.0.0 — 2025-01-16

## README

<div align="center">
  <h1>@rc-component/segmented</h1>
  <p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p>
  <p>🧩 React segmented control for switching between compact options.</p>

  <p>
    <a href="https://npmjs.org/package/@rc-component/segmented"><img alt="NPM version" src="https://img.shields.io/npm/v/@rc-component/segmented.svg?style=flat-square"></a>
    <a href="https://npmjs.org/package/@rc-component/segmented"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@rc-component/segmented.svg?style=flat-square"></a>
    <a href="https://github.com/react-component/segmented/actions/workflows/react-component-ci.yml"><img alt="build status" src="https://github.com/react-component/segmented/actions/workflows/react-component-ci.yml/badge.svg"></a>
    <a href="https://app.codecov.io/gh/react-component/segmented"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/react-component/segmented/master.svg?style=flat-square"></a>
    <a href="https://bundlephobia.com/package/@rc-component/segmented"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@rc-component/segmented?style=flat-square"></a>
    <a href="https://github.com/umijs/dumi"><img alt="dumi" src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square"></a>
  </p>
</div>

<p align="center">English | <a href="./README.zh-CN.md">简体中文</a></p>


## Highlights

- Supports string, number, and labeled option records.
- Provides controlled and uncontrolled value flows.
- Includes keyboard navigation, RTL, vertical layout, and disabled options.
- Exposes semantic `classNames` and `styles` slots for item and label customization.

## Install

```bash
npm install @rc-component/segmented
```

## Usage

```tsx pure
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/

## Examples

Run the local dumi site:

```bash
npm install
npm start
```

Then open `http://localhost:8000`.

## API

### Segmented

| 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.

### SegmentedLabeledOption

| 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. |

## Development

```bash
npm install
npm start
npm test
npm run tsc
npm run compile
npm run build
```

The dumi site runs at `http://localhost:8000` by default.

## Release

```bash
npm run prepublishOnly
```

The release flow is handled by `@rc-component/np` through the `rc-np` command after the package build.

## License

@rc-component/segmented is released under the [MIT](./LICENSE) license.

---
_Source: https://npm.io/package/@rc-component/segmented · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
