Segment
A segmented control component for selecting between options.
Installation
npm install @cleartrip/ct-design-segment
# or
pnpm add @cleartrip/ct-design-segment
Peer dependencies
# Required for all targets
npm install react
# Web only
npm install react-dom
# React Native only
npm install react-native
Usage
Basic
import { Segment } from '@cleartrip/ct-design-segment';
function Example() {
return (
<Segment>
{/* Basic usage */}
</Segment>
);
}
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
block | boolean | — | No | If true, the segment takes the full width of its parent. |
disabled | boolean | — | No | Disables all segment options. |
variant | SegmentVariantType | — | No | Visual variant for the segment. |
enableTabClick | boolean | — | No | Allow onChange to fire even when an option is disabled. |
onChange | `(value: string | number) => void` | — | ✅ Yes |
options | IOption[] | — | ✅ Yes | Options rendered inside the segment. |
activeTabId | string | — | No | Controlled active tab id. |
animationDuration | number | — | No | Duration (ms) of the indicator slide animation. |
styleConfig | SegmentStyleConfigProps | — | No | Per-slot style overrides. |
SegmentVariant
DEFAULT— defaultDARK— dark
Accessibility
- The component follows accessibility best practices
- Ensure proper ARIA attributes are provided where needed
- Test with screen readers to ensure usability
Migration
If migrating from a previous version:
- import { Segment } from 'yagami/core/components';
+ import { Segment } from '@cleartrip/ct-design-segment';