logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
YouMindTRACTIANLobeHubCodeRabbit
6.4.5
  • Components Overview
  • Changelog
    v6.4.5
  • General
    • Button
    • FloatButton
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
    • Grid
    • Layout
    • Masonry
      6.0.0
    • Space
    • Splitter
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
    • Tabs
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPicker
    • 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
      DEPRECATED
    • Popover
    • QRCode
    • Segmented
    • Statistic
    • Table
    • Tag
    • Timeline
    • Tooltip
    • Tour
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • App
    • BorderBeam
      6.4.0
    • ConfigProvider
    • Util
When To Use
Examples
Basic
Vertical Direction
Block Segmented
Round shape
Disabled
Controlled mode
Custom Render
Dynamic
Three sizes of Segmented
With Icon
With Icon only
With name
Custom semantic dom styling
API
Segmented
SegmentedItemType
Semantic DOM
Design Token

Segmented

Display multiple options and allow users to select a single option.
Importimport { Segmented } from 'antd';
GitHub
components/segmentedIssueOpen issues
Docs
Edit this pageLLMs.md
QRCodeStatistic

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
X
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
For Agents
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
WeaveFox logoWeaveFox-AI Development with WeaveFox 🦊
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

Segmented

PropertyDescriptionTypeDefaultVersionGlobal Config
blockOption to fit width to its parent's widthbooleanfalse×
classNamesCustomize class for each semantic structure inside the Segmented component. Supports object or function.Record<SemanticDOM, string> | (info: { props }) => Record<SemanticDOM, string>-6.0.0
defaultValueDefault selected valuestring | numberValue of first item in options×
disabledDisable all segmentsbooleanfalse×
onChangeThe callback function that is triggered when the state changesfunction(value: string | number)×
optionsSet children optionalstring[] | number[] | SegmentedItemType[][]×
orientationOrientationhorizontal | verticalhorizontal×
sizeThe size of the Segmented.large | medium | smallmedium×
stylesCustomize inline style for each semantic structure inside the Segmented component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props }) => Record<SemanticDOM, CSSProperties>-6.0.0
verticalOrientation. Simultaneously existing with orientation, orientation takes prioritybooleanfalse5.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
disabledDisabled state of segmented itembooleanfalse
classNameThe additional css classstring-
iconDisplay icon for Segmented itemReactNode-
labelDisplay text for Segmented itemReactNode-
tooltiptooltip for Segmented itemstring | TooltipProps-
valueValue for Segmented itemstring | number-

Semantic DOM

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?
Token NameDescriptionTypeDefault Value
colorPrimaryBorderThe stroke color under the main color gradient, used on the stroke of components such as Slider.string#91caff
colorTextDefault text color which comply with W3C standards, and this color is also the darkest neutral color.stringrgba(0,0,0,0.88)
colorTextDisabledControl the color of text in disabled state.stringrgba(0,0,0,0.25)
borderRadiusBorder radius of base componentsnumber6
borderRadiusLGLG size border radius, used in some large border radius components, such as Card, Modal and other components.number8
borderRadiusSMSM size border radius, used in small size components, such as Button, Input, Select and other input components in small sizenumber4
borderRadiusXSXS size border radius, used in some small border radius components, such as Segmented, Arrow and other components with small border radius.number2
boxShadowTertiaryControl the tertiary box shadow style of an element.string 0 1px 2px 0 rgba(0,0,0,0.05), 0 1px 6px -1px rgba(0,0,0,0.03), 0 2px 4px 0 rgba(0,0,0,0.03)
controlHeightThe height of the basic controls such as buttons and input boxes in Ant Designnumber32
controlHeightLGLG component heightnumber40
controlHeightSMSM component heightnumber24
controlPaddingHorizontalControl the horizontal padding of an element.number12
controlPaddingHorizontalSMControl the horizontal padding of an element with a small-medium size.number8
fontFamilyThe font family of Ant Design prioritizes the default interface font of the system, and provides a set of alternative font libraries that are suitable for screen display to maintain the readability and readability of the font under different platforms and browsers, reflecting the friendly, stable and professional characteristics.string-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSizeThe most widely used font size in the design system, from which the text gradient will be derived.number14
fontSizeLGLarge font sizenumber16
lineHeightLine height of text.number1.5714285714285714
lineWidthBorder width of base componentsnumber1
lineWidthFocusControl the width of the line when the component is in focus state.number3
marginSMControl the margin of an element, with a medium-small size.number12
motionDurationMidMotion speed, medium speed. Used for medium element animation interaction.string0.2s
motionDurationSlowMotion speed, slow speed. Used for large element animation interaction.string0.3s
motionEaseInOutPreset motion curve.string
Cubic Bezier Visualizer
cubic-bezier(0.645, 0.045, 0.355, 1)External Link Icon
paddingXXSControl the extra extra small padding of the element.number4
Basic

The most basic usage.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Block Segmented

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Disabled

Disabled Segmented.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom Render

Custom each Segmented Item.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Three sizes of Segmented

There are three sizes of a Segmented component: large (40px), medium (32px), and small (24px).

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
With Icon only

Set icon without label for Segmented Item.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom semantic dom styling

You can customize the semantic dom style of the Segmented by passing objects/functions through classNames and styles.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
6.0.0
Vertical Direction

Make it vertical.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5.21.0
Round shape

Round shape of Segmented.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5.24.0
Controlled mode

Controlled Segmented.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Dynamic

Load options dynamically.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
With Icon

Set icon for Segmented Item.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
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
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5.23.0
  • root
    6.0.0
    Root element with inline-block layout, padding, background, border radius, transition and container styles
  • item
    6.0.0
    Option element with relative positioning, text alignment, cursor style, transition, selected state background and hover styles
  • label
    6.0.0
    Label content element with min height, line height, padding, text ellipsis and content layout styles
  • icon
    6.0.0
    Icon element with icon size, color and text spacing styles