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

Button

To trigger an operation.
Importimport{ Button }from"antd";
Sourcecomponents/button
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

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 can be 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 can be removed by setting autoInsertSpace to false.booleantrue5.17.0
blockOption to fit button width to its parent widthbooleanfalse
classNamesSemantic DOM classRecord<SemanticDOM, string>-5.4.0
dangerSet the danger status of buttonbooleanfalse
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: MDNstringbutton
iconSet the icon component of buttonReactNode-
iconPositionSet the icon position of buttonstart | endstart5.17.0
loadingSet the loading status of buttonboolean | { delay: number }false
shapeCan be set button shapedefault | circle | rounddefault
sizeSet the size of buttonlarge | middle | smallmiddle
stylesSemantic DOM styleRecord<SemanticDOM, CSSProperties>-5.4.0
targetSame as target attribute of a, works when href is specifiedstring-
typeSet button typeprimary | dashed | link | text | defaultdefault
onClickSet the handler to handle click event(event: React.MouseEvent<HTMLElement, MouseEvent>) => void-

It accepts all props which native buttons support.

Semantic DOM

Design Token

Component TokenHow to use?

Token NameDescriptionTypeDefault Value
borderColorDisabledBorder color of disabled buttonstring#d9d9d9
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)
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
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 textundefined | FontWeight400
ghostBgBackground color of ghost buttonstringtransparent
groupBorderColorBorder color of button groupstring#4096ff
linkHoverBgBackground color of link button when hoverstringtransparent
onlyIconSizeIcon size of button which only contains iconnumber16
onlyIconSizeLGIcon size of large button which only contains iconnumber18
onlyIconSizeSMIcon size of small button which only contains iconnumber14
paddingBlockVertical padding of buttonundefined | PaddingBlock<string | number>4
paddingBlockLGVertical padding of large buttonundefined | PaddingBlock<string | number>7
paddingBlockSMVertical padding of small buttonundefined | PaddingBlock<string | number>0
paddingInlineHorizontal padding of buttonundefined | PaddingInline<string | number>15
paddingInlineLGHorizontal padding of large buttonundefined | PaddingInline<string | number>15
paddingInlineSMHorizontal padding of small buttonundefined | PaddingInline<string | number>7
primaryColorText color of primary buttonstring#fff
primaryShadowShadow of primary buttonstring0 2px 0 rgba(5, 145, 255, 0.1)
textHoverBgBackground color of text button when hoverstringrgba(0, 0, 0, 0.06)

Global TokenHow to use?

FAQ

How to close the click wave effect?

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

<ConfigProvider wave={{ disabled: true }}>
<Button>click</Button>
</ConfigProvider>
Type

There are five type of buttons in antd, namely they are: primary buttons, default buttons, dashed buttons, text buttons, and link buttons.

codepen icon
External Link Icon
expand codeexpand code
Icon Position

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

codepen icon
External Link Icon
expand codeexpand code
5.17.0
Disabled

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

codepen icon
External Link Icon
expand codeexpand code
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.Button.

codepen icon
External Link Icon
expand codeexpand code
Danger Buttons

The danger is a property of buttons after antd 4.0.

codepen icon
External Link Icon
expand codeexpand code
Gradient Button

Buttons with a gradient background.

codepen icon
External Link Icon
expand codeexpand code
Icon

You can add an icon using the icon property.

codepen icon
External Link Icon
expand codeexpand code
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.

codepen icon
External Link Icon
expand codeexpand code
Loading

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

codepen icon
External Link Icon
expand codeexpand code
Ghost Button

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

codepen icon
External Link Icon
expand codeexpand code
Block Button

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

codepen icon
External Link Icon
expand codeexpand code
Preview
Href PrimaryHref Primary(disabled)
Preview
  • icon
    5.5.0
    Icon element