Button
To trigger an operation.
When To Use
A button means an operation (or a series of operations). Clicking a button will trigger corresponding business logic.
In Ant Design we provide 4 types of button.
- Primary button: indicate the main action, one primary button at most in one section.
- Default button: indicate a series of actions without priority.
- Dashed button: used for adding action commonly.
- 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
: when actions is not available.loading
: add loading spinner in button, avoiding multiple submits too.
Examples
Button API#
Property | Description | Type | Default Value |
---|---|---|---|
AriaLabel | ParameterSets the value of the aria-label attribute | String | -- |
Color | ParameterSet the color of the button. | Color | Color.None |
Block | ParameterOption to fit button width to its parent width | Boolean | false |
ChildContent | ParameterContent of the button. | RenderFragment | -- |
Danger | ParameterSet the danger status of button. | Boolean | false |
Disabled | ParameterWhether the `Button` is disabled. | Boolean | false |
Ghost | ParameterMake background transparent and invert text and border colors | Boolean | false |
HtmlType | ParameterSet the original html type of the button element. | String | button |
Icon | ParameterSet the icon component of button. | String | -- |
Loading | ParameterShow loading indicator. You have to write the loading logic on your own. | Boolean | false |
AutoLoading | ParameterWhether to trigger and keep the loading state until the event callback is done. | Boolean | -- |
OnClick | ParameterCallback when `Button` is clicked | EventCallback<MouseEventArgs> | -- |
OnClickStopPropagation | ParameterDo not propagate events when button is clicked. | Boolean | -- |
Shape | ParameterCan set button shape: `circle` | `round` or `null` (default, which is rectangle). | String | null |
Size | ParameterSet the size of button. | String | AntSizeLDSType.Default |
Type | ParameterType of the button. | String | ButtonType.Default |
NoSpanWrap | ParameterDo not wrap with <span> | Boolean | -- |
Id | ParameterID for the component's HTML | String | Uniquely Generated ID |
Class | ParameterSpecifies one or more class names for an DOM element. | String | -- |
Style | ParameterSpecifies an inline style for a DOM element. | String | -- |
RefBack | ParameterA ForwardRef instance. You can get a reference to the internal DOM by using AntDesign.ForwardRef.Current . |
ForwardRef | -- |
DownloadButton API#
Property | Description | Type | Default Value |
---|---|---|---|
Url | ParameterThe download url of a file | String | -- |
FileName | ParameterName of the file | String | -- |
AriaLabel | ParameterSets the value of the aria-label attribute | String | -- |
Color | ParameterSet the color of the button. | Color | Color.None |
Block | ParameterOption to fit button width to its parent width | Boolean | false |
ChildContent | ParameterContent of the button. | RenderFragment | -- |
Danger | ParameterSet the danger status of button. | Boolean | false |
Disabled | ParameterWhether the `Button` is disabled. | Boolean | false |
Ghost | ParameterMake background transparent and invert text and border colors | Boolean | false |
HtmlType | ParameterSet the original html type of the button element. | String | button |
Icon | ParameterSet the icon component of button. | String | -- |
Loading | ParameterShow loading indicator. You have to write the loading logic on your own. | Boolean | false |
AutoLoading | ParameterWhether to trigger and keep the loading state until the event callback is done. | Boolean | -- |
OnClick | ParameterCallback when `Button` is clicked | EventCallback<MouseEventArgs> | -- |
OnClickStopPropagation | ParameterDo not propagate events when button is clicked. | Boolean | -- |
Shape | ParameterCan set button shape: `circle` | `round` or `null` (default, which is rectangle). | String | null |
Size | ParameterSet the size of button. | String | AntSizeLDSType.Default |
Type | ParameterType of the button. | String | ButtonType.Default |
NoSpanWrap | ParameterDo not wrap with <span> | Boolean | -- |
Id | ParameterID for the component's HTML | String | Uniquely Generated ID |
Class | ParameterSpecifies one or more class names for an DOM element. | String | -- |
Style | ParameterSpecifies an inline style for a DOM element. | String | -- |
RefBack | ParameterA ForwardRef instance. You can get a reference to the internal DOM by using AntDesign.ForwardRef.Current . |
ForwardRef | -- |