logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
5.20.6
  • Components Overview
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Space
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • 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
    • Tabs
    • 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
DocsEdit this page

Resources

Ant Design Charts
Ant Design Pro
Ant Design Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
ahooks-React Hooks Library
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
valueCurrently selected valuestring | number

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.

codepen icon
External Link Icon
expand codeexpand code
Disabled

Disabled Segmented.

codepen icon
External Link Icon
expand codeexpand code
Custom Render

Custom each Segmented Item by ReactNode.

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

codepen icon
External Link Icon
expand codeexpand code
With Icon only

Set icon without label for Segmented Item.

codepen icon
External Link Icon
expand codeexpand code
Block Segmented

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

codepen icon
External Link Icon
expand codeexpand code
Controlled mode

Controlled Segmented.

codepen icon
External Link Icon
expand codeexpand code
Dynamic

Load options dynamically.

codepen icon
External Link Icon
expand codeexpand code
With Icon

Set icon for Segmented Item.

codepen icon
External Link Icon
expand codeexpand code