logoAnt Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
6.0.0-alpha.3
  • Components Overview
  • Changelog
    v6.0.0-alpha.3
  • General
    • Button
    • FloatButton
      5.0.0
    • Icon
    • Typography
  • Layout
    • Divider
    • Flex
      5.10.0
    • Grid
    • Layout
    • Masonry
      6.0.0
    • 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
      DEPRECATED
    • 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
When To Use
Examples
Syntactic sugar
Color & Variant
Icon
Icon Placement
Size
Disabled
Loading
Multiple Buttons
Ghost Button
Danger Buttons
Block Button
Gradient Button
Custom disabled backgroundColor
Custom semantic dom styling
API
PresetColors
Semantic DOM
Design Token
FAQ
How to choose type and color & variant?
How to close the click wave effect?

Button

To trigger an operation.
Importimport { Button } from "antd";
GitHub
components/buttonIssueOpen issues
Docs
Edit this pageDesign
contributors
ChangelogFloatButton

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

When To Use

A button means an operation (or a series of operations). Clicking a button will trigger its corresponding business logic.

In Ant Design we provide 5 types of button.

  • 🔵 Primary button: used for the main action, there can be at most one primary button in a section.
  • ⚪️ Default button: used for a series of actions without priority.
  • 😶 Dashed button: commonly used for adding more actions.
  • 🔤 Text button: used for the most secondary action.
  • 🔗 Link button: used for external links.

And 4 other properties additionally.

  • 🔴 danger: used for actions of risk, like deletion or authorization.
  • 👻 ghost: used in situations with complex background, home pages usually.
  • 🚫 disabled: used when actions are not available.
  • 🔃 loading: adds a loading spinner in button, avoids multiple submits too.

Examples

API

Common props ref:Common props

Different button styles generated by setting Button properties. The recommended order is: type -> shape -> size -> loading -> disabled.

PropertyDescriptionTypeDefaultVersion
autoInsertSpaceWe add a space between two Chinese characters by default, which removed by setting autoInsertSpace to false.booleantrue5.17.0
blockOption to fit button width to its parent widthbooleanfalse
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
colorSet button colordefault | primary | danger | PresetColors-default, primary and danger: 5.21.0, PresetColors: 5.23.0
dangerSyntactic sugar. Set the danger status of button. will follow color if providedbooleanfalse
disabledDisabled state of buttonbooleanfalse
ghostMake background transparent and invert text and border colorsbooleanfalse
hrefRedirect url of link buttonstring-
htmlTypeSet the original html type of button, see: MDNsubmit | reset | buttonbutton
iconSet the icon component of buttonReactNode-
iconPositionSet the icon position of button, please use iconPlacement insteadstart | endstart5.17.0
iconPlacementSet the icon position of buttonstart | endstart-
loadingSet the loading status of buttonboolean | { delay: number, icon: ReactNode }falseicon: 5.23.0
shapeCan be used to set button shapedefault | circle | rounddefault
sizeSet the size of buttonlarge | middle | smallmiddle
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-
targetSame as target attribute of a, works when href is specifiedstring-
typeSyntactic sugar. Set button type. Will follow variant & color if providedprimary | dashed | link | text | defaultdefault
onClickSet the handler to handle click event(event: React.MouseEvent<HTMLElement, MouseEvent>) => void-
variantSet button variantoutlined | dashed | solid | filled | text | link-5.21.0

It accepts all props which native buttons support.

PresetColors

type PresetColors = 'blue' | 'purple' | 'cyan' | 'green' | 'magenta' | 'pink' | 'red' | 'orange' | 'yellow' | 'volcano' | 'geekblue' | 'lime' | 'gold';

Semantic DOM

Design Token

Component TokenHow to use?
Token NameDescriptionTypeDefault Value
contentFontSizeFont size of button contentnumber14
contentFontSizeLGFont size of large button contentnumber16
contentFontSizeSMFont size of small button contentnumber14
contentLineHeightLine height of button contentnumber1.5714285714285714
contentLineHeightLGLine height of large button contentnumber1.5
contentLineHeightSMLine height of small button contentnumber1.5714285714285714
dangerColorText color of danger buttonstring#fff
dangerShadowShadow of danger buttonstring0 2px 0 rgba(255,38,5,0.06)
dashedBgDisabledstringrgba(0,0,0,0.04)
defaultActiveBgBackground color of default button when activestring#ffffff
defaultActiveBorderColorBorder color of default button when activestring#0958d9
defaultActiveColorText color of default button when activestring#0958d9
defaultBgBackground color of default buttonstring#ffffff
defaultBgDisabledstringrgba(0,0,0,0.04)
defaultBorderColorBorder color of default buttonstring#d9d9d9
defaultColorText color of default buttonstringrgba(0,0,0,0.88)
defaultGhostBorderColorBorder color of default ghost buttonstring#ffffff
defaultGhostColorText color of default ghost buttonstring#ffffff
defaultHoverBgBackground color of default button when hoverstring#ffffff
defaultHoverBorderColorBorder color of default buttonstring#4096ff
defaultHoverColorText color of default button when hoverstring#4096ff
defaultShadowShadow of default buttonstring0 2px 0 rgba(0,0,0,0.02)
fontWeightFont weight of textFontWeight | undefined400
ghostBgBackground color of ghost buttonstringtransparent
groupBorderColorBorder color of button groupstring#4096ff
iconGapGap between icon and textGap<string | number> | undefined8
linkHoverBgBackground color of link button when hoverstringtransparent
onlyIconSizeIcon size of button which only contains iconstring | numberinherit
onlyIconSizeLGIcon size of large button which only contains iconstring | numberinherit
onlyIconSizeSMIcon size of small button which only contains iconstring | numberinherit
paddingBlockVertical padding of buttonPaddingBlock<string | number> | undefined4
paddingBlockLGVertical padding of large buttonPaddingBlock<string | number> | undefined7
paddingBlockSMVertical padding of small buttonPaddingBlock<string | number> | undefined0
paddingInlineHorizontal padding of buttonPaddingInline<string | number> | undefined15
paddingInlineLGHorizontal padding of large buttonPaddingInline<string | number> | undefined15
paddingInlineSMHorizontal padding of small buttonPaddingInline<string | number> | undefined7
primaryColorText color of primary buttonstring#fff
primaryShadowShadow of primary buttonstring0 2px 0 rgba(5,145,255,0.1)
solidTextColorDefault text color for solid buttons.string#fff
textHoverBgBackground color of text button when hoverstringrgba(0,0,0,0.04)
textTextActiveColorDefault text color for text buttons on activestringrgba(0,0,0,0.88)
textTextColorDefault text color for text buttonsstringrgba(0,0,0,0.88)
textTextHoverColorDefault text color for text buttons on hoverstringrgba(0,0,0,0.88)
Global TokenHow to use?

FAQ

How to choose type and color & variant?

Type is essentially syntactic sugar for colors and variants. It internally provides a set of mapping relationships between colors and variants for the type. If both exist at the same time, the colors and variants will be used first.

jsx
<Button type="primary">click</Button>

Equivalent

jsx
<Button color="primary" variant="solid">
click
</Button>

How to close the click wave effect?

If you don't need this feature, you can set disabled of wave in ConfigProvider as true.

jsx
<ConfigProvider wave={{ disabled: true }}>
<Button>click</Button>
</ConfigProvider>
Syntactic sugar

Through the type syntactic sugar, use the preset button styles: primary buttons, default buttons, dashed buttons, text buttons, and link buttons.

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

You can add an icon using the icon property.

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

Ant Design supports three sizes of buttons: small, default and large.

If a large or small button is desired, set the size property to either large or small respectively. Omit the size property for a button with the default size.

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

A loading indicator can be added to a button by setting the loading property on the Button. The loading.icon can be used to customize the loading icon.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Ghost Button

The ghost property will make a button's background transparent, this is commonly used in colored background.

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

The block property will make a button fit to its parent width.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Custom disabled backgroundColor

Customize the background color with disable (applicable to type default and dashed)

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Color & Variant

You can set the color and variant attributes at the same time can derive more variant buttons.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
5.21.0
Icon Placement

You can set the position of a button's icon by setting the iconPlacement to start or end respectively.

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

To mark a button as disabled, add the disabled property to the Button.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Multiple Buttons

If you need several buttons, we recommend that you use 1 primary button + n secondary buttons. If there are more than three operations, you can group some of them into a Dropdown.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Danger Buttons

The danger is a property of buttons after antd 4.0.

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
Gradient Button

Buttons with a gradient background.

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

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

CodeSandbox Icon
Hitu Icon
codepen icon
External Link Icon
Expand Icon
6.0.0
Preview
Preview
Href PrimaryHref Primary(disabled)
  • root
    6.0.0
    Root element with comprehensive button styling including border, background, padding, border-radius, box-shadow, transitions, cursor, font-weight, alignment, and layout properties
  • icon
    5.5.0
    Icon element with font-size, color inheritance, and SVG style reset for proper icon display
  • content
    6.0.0
    Content element that wraps button text with typography styles including nowrap, text-align center, and Chinese character spacing optimization