JGuang

Button

Button · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

Button

Used to start an immediate operation.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Used to start an immediate operation.

When to Use

Marks or encapsulates a group of operation commands, responds to user click behavior, and triggers corresponding business logic.

Demos

Button

Props

NameDescriptionTypeDefault
blockShould the button displays as block element.booleanfalse
colorThe color of the button.'default' | 'primary' | 'success' | 'warning' | 'danger''default'
disabledShould the button be disabled.booleanfalse
fillThe fill mode.'solid' | 'outline' | 'none''solid'
loadingShould the button displays as loading state. 'auto' will update loading state based on the Promise state of onClickboolean | 'auto'false
loadingIconThe customized icon in loading state.ReactNode<DotLoading color='currentColor' />
loadingTextThe extra text displayed in loading state.string-
onClickThe click event.(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Promise<void>-
shapeThe shape of the button.'default' | 'rounded' | 'rectangular''default'
sizeThe size of the button.'mini' | 'small' | 'middle' | 'large''middle'
typeThe type prop of native button element.'submit' | 'reset' | 'button''button'

In addition, the following properties of the native button element are supported: onMouseDown onMouseUp onTouchStart onTouchEnd form.

CSS Variables

NameDescriptionDefaultGlobal
--background-colorBackground color of the button.var(--adm-color-background)--adm-button-background-color
--border-colorBorder color of the button.var(--adm-color-border)--adm-button-border-color
--border-radiusBorder radius of the button.4px--adm-button-border-radius
--border-styleBorder style of the button.solid--adm-button-border-style
--border-widthBorder width of the button.1px--adm-button-border-width
--text-colorText color of the button.var(--adm-color-text)--adm-button-text-color

Ref

NameDescriptionType
nativeElementNative button elementHtmlButtonElement | null