Skip to content

ActionSheet

A panel that slides up from the bottom, presenting a set of options.

Basic Usage

The visible attribute controls whether the action sheet is displayed. The actions attribute is an array of objects, each object in the array represents an option in the action sheet. The name attribute is the name of the option, and the color attribute is the text color of the option.

html
<wd-button @click="show = true">Open ActionSheet</wd-button>
<wd-action-sheet :visible.sync="show" :actions="actions" @select="handleSelect" />
typescript
import { reactive, toRefs } from 'vue'

export default {
  setup() {
    const state = reactive({
      show: false,
      actions: [
        {
          name: 'Option 1'
        },
        {
          name: 'Option 2'
        },
        {
          name: 'Option 3',
          color: '#4D80F0'
        }
      ]
    })

    const handleSelect = item => {
      console.log(item)
    }

    return {
      ...toRefs(state),
      handleSelect
    }
  }
}

Cancel Button

Set the cancel-text attribute to display a cancel button at the bottom of the action sheet.

html
<wd-action-sheet :visible.sync="show" :actions="actions" cancel-text="Cancel" />

Title

Set the title attribute to display a title at the top of the action sheet.

html
<wd-action-sheet :visible.sync="show" :actions="actions" title="Title" />

Option Status

The actions array can set the disabled attribute to disable an option, and the loading attribute to set an option to loading state.

html
<wd-action-sheet :visible.sync="show" :actions="actions" />
typescript
export default {
  data() {
    return {
      show: false,
      actions: [
        {
          name: 'Option 1',
          disabled: true
        },
        {
          name: 'Option 2',
          loading: true
        },
        {
          name: 'Option 3'
        }
      ]
    }
  }
}

Custom Panel

The action sheet can be used with a slot to customize the panel content.

html
<wd-action-sheet :visible.sync="show" title="Custom Panel">
  <view style="padding: 15px 15px 150px 15px; color: #333333; font-size: 16px;">
    Custom Content
  </view>
</wd-action-sheet>

Attributes

AttributeDescriptionTypeDefaultVersion
visibleWhether to display the action sheet, supports the .sync modifierbooleanfalse-
actionsOptionsAction[][]-
titleTitlestring--
cancel-textCancel button textstring--
close-on-click-actionWhether to close the action sheet when clicking an optionbooleantrue-
close-on-click-modalWhether to close the action sheet when clicking the modalbooleantrue-
durationAnimation durationnumber200(ms)-
z-indexz-indexnumber10-
lazy-renderWhether to lazily render the action sheetbooleantrue-
safe-area-inset-bottomWhether to enable bottom safe area adaptationbooleantrue1.0.0

Action Options

KeyDescriptionTypeDefaultVersion
nameOption namestring--
subnameOption subnamestring--
colorOption text colorstring--
disabledWhether to disable the optionbooleanfalse-
loadingWhether to display loading statusbooleanfalse-

Events

Event NameDescriptionParametersVersion
selectTriggered when an option is clickeditem: selected option, index: option index-
openTriggered when the action sheet is opened--
openedTriggered when the action sheet opening animation ends--
closeTriggered when the action sheet is closed--
closedTriggered when the action sheet closing animation ends--
click-modalTriggered when the modal is clicked--
cancelTriggered when the cancel button is clicked--

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.