button

Button.

Scan QR code to try:

button

Property

TypeDefaultDescription
sizeStringdefault Effective value default, mini.
typeStringdefaultButton style type, effective value primary, default, warn.
plainBooleanfalseHollow or not.
disabledBooleanfalseDisable or not.
loadingBooleanfalseButton text preceded with loading icon or not.
hover-classStringbutton-hoverButton pressed style class hover-class="none" indicates no pressed effect.
hover-start-timeNumber20Pressed status shown in a period after being pressed, in milliseconds.
hover-stay-timeNumber70Pressed status retention time after release, in milliseconds.
form-typeStringEffective value submit and reset, used for component, clicking triggers submit/reset event respectively.
onTapEventHandleClick.
open-typeStringOpen ability.
scopeStringValid when open-type is getAuthorize.

The Valid Value of open-type

ValueDescription
getAuthorizeSupport for Mini Program authorization.

The Valid Value of Scope

When open-type is getAuthorize , we can set scope to the following value:

ValueDescription
userInfoet user basic information.
phoneNumberGet user's phone number.

Screenshot

button

Sample Code

copy
<view class="page">
  <view class="section">
    <view class="title">Type</view>
    <button type="default">default</button>
    <button type="primary">primary</button>
    <button type="warn">warn</button>
  </view>
  <view class="section" style="background:#ddd;">
    <view class="title">Misc</view>
    <button type="default" plain>plain</button>
    <button type="default" disabled>disabled</button>
    <button type="default" loading={{true}}>loading</button>
    <button type="default" hover-class="red">hover-red</button>
  </view>
  <view class="section">
    <view class="title">Size</view>
    <button type="default" size="mini">mini</button>
  </view>
  <view class="section">
    <view class="title">Type</view>
    <form onSubmit="onSubmit" onReset="onReset">
      <button form-type="submit">submit</button>
      <button form-type="reset">reset</button>
    </form>
  </view>
</view>