logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
5.25.0
  • Components Overview
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Space
    • Splitter
      5.21.0
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
      5.5.0
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
    • Popover
    • QRCode
      5.1.0
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
      5.0.0
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
      5.1.0
  • Other
    • Affix
    • App
      5.1.0
    • ConfigProvider
    • Util
      5.13.0

Segmented

Display multiple options and allow users to select a single option.
Importimport { Segmented } from "antd";
Sourcecomponents/segmented
Docs
Edit this pageChangelog

Resources

Ant Design X
Ant Design Charts
Ant Design Pro
Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Web3
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
Twitter
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community
loading

This component is available since antd@4.20.0.

When To Use

  • When displaying multiple options and user can select a single option;
  • When switching the selected option, the content of the associated area changes.

Examples

API

Common props ref:Common props

This component is available since antd@4.20.0

PropertyDescriptionTypeDefaultVersion
blockOption to fit width to its parent's widthbooleanfalse
defaultValueDefault selected valuestring | number
disabledDisable all segmentsbooleanfalse
onChangeThe callback function that is triggered when the state changesfunction(value: string | number)
optionsSet children optionalstring[] | number[] | SegmentedItemType[][]
sizeThe size of the Segmented.large | middle | smallmiddle
verticalOrientationbooleanfalse5.21.0
valueCurrently selected valuestring | number
shapeshape of Segmenteddefault | rounddefault5.24.0
nameThe name property of all input[type="radio"] children. if not set, it will fallback to a randomly generated namestring5.23.0

SegmentedItemType

PropertyDescriptionTypeDefaultVersion
labelDisplay text for Segmented itemReactNode-
valueValue for Segmented itemstring | number-
iconDisplay icon for Segmented itemReactNode-
disabledDisabled state of segmented itembooleanfalse
classNameThe additional css classstring-

Design Token

Component TokenHow to use?
Token NameDescriptionTypeDefault Value
itemActiveBgBackground color of item when activestringrgba(0,0,0,0.15)
itemColorText color of itemstringrgba(0,0,0,0.65)
itemHoverBgBackground color of item when hoverstringrgba(0,0,0,0.06)
itemHoverColorText color of item when hoverstringrgba(0,0,0,0.88)
itemSelectedBgBackground color of item when selectedstring#ffffff
itemSelectedColorText color of item when selectedstringrgba(0,0,0,0.88)
trackBgBackground of Segmented containerstring#f5f5f5
trackPaddingPadding of Segmented containerstring | number2
Global TokenHow to use?
Basic

The most basic usage.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Block Segmented

block property will make the Segmented fit to its parent width.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Disabled

Disabled Segmented.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Custom Render

Custom each Segmented Item by ReactNode.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Three sizes of Segmented

There are three sizes of an Segmented: large (40px), default (32px) and small (24px).

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
With Icon only

Set icon without label for Segmented Item.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Vertical Direction

Make it vertical.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
5.21.0
Round shape

Round shape of Segmented.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
5.24.0
Controlled mode

Controlled Segmented.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Dynamic

Load options dynamically.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
With Icon

Set icon for Segmented Item.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
With name

Passing the name property to all input[type="radio"] that are in the same Segmented. It is usually used to let the browser see your Segmented as a real "group" and keep the default behavior. For example, using left/right keyboard arrow to change your selection that in the same Segmented.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
5.23.0