Skip to content

ActionSheet ​

Action menu panel that pops up from the bottom.

Component Type ​

Basic Usage ​

Control show/hide through v-model.

The actions type is Array, with the following object structure:

ParameterDescriptionType
nameOption namestring
descriptionDescription infostring
colorColorstring
html
<wd-toast />
<wd-button @click="showActions">Show Menu</wd-button>
<wd-action-sheet v-model="show" :actions="actions" @close="close" @select="select" />
typescript
const show = ref<boolean>(false)
const actions = ref([
  {
    name: 'Option 1'
  },
  {
    name: 'Option 2'
  },
  {
    name: 'Option 3',
    description: 'Description info'
  }
])

function showActions() {
  show.value = true
}

function close() {
  show.value = false
}

const toast = useToast()

function select({ item, index }) {
  toast.show(`Current selection: ${item.name}, index: ${index}`)
}

Custom Single Row Panel ​

When using custom single row panel, panels type is a one-dimensional array with the following object structure:

ParameterDescriptionType
iconIcon name or image URLstring
titleTitlestring
html
<wd-button @click="showActions">Show Menu</wd-button>
<wd-action-sheet v-model="show" :panels="panels" @close="close" @select="select" />
typescript
const show = ref<boolean>(false)
const panels = ref([
  {
    icon: 'user',
    title: 'WeChat Friends'
  },
  {
    icon: 'share-internal',
    title: 'Moments'
  },
  {
    icon: 'message',
    title: 'QQ Friends'
  },
  {
    icon: 'star-fill',
    title: 'Favorites'
  },
  {
    icon: 'share-internal',
    title: 'More Share'
  },
  {
    icon: 'user-add',
    title: 'Invite Friends'
  }
])
function showActions() {
  show.value = true
}

function close() {
  show.value = false
}
const toast = useToast()

function select({ item, index }) {
  toast.show(`Current selection: ${item.title}, index: ${index}`)
}

Custom Multi-Row Panel ​

When using custom multi-row panel, panels type is a multi-dimensional array with the following object structure:

ParameterDescriptionType
iconIcon name or image URLstring
titleTitlestring
html
<wd-button @click="showActions">Show Menu</wd-button>
<wd-action-sheet v-model="show" :panels="panels" @close="close" @select="select1" />
typescript
const show = ref<boolean>(false)
const panels = ref([
  [
    {
      icon: 'user',
      title: 'WeChat Friends'
    },
    {
      icon: 'share-internal',
      title: 'Moments'
    },
    {
      icon: 'message',
      title: 'QQ Friends'
    },
    {
      icon: 'star-fill',
      title: 'Favorites'
    },
    {
      icon: 'user-add',
      title: 'Invite'
    },
    {
      icon: 'share-external',
      title: 'External Share'
    },
    {
      icon: 'qrcode',
      title: 'Generate QR Code'
    },
    {
      icon: 'save',
      title: 'Save Image'
    }
  ],
  [
    {
      icon: 'file-image',
      title: 'Image'
    },
    {
      icon: 'download',
      title: 'Download'
    },
    {
      icon: 'copy',
      title: 'Copy Link'
    }
  ]
])

function showActions() {
  show.value = true
}

function close() {
  show.value = false
}
const toast = useToast()

function select1({ item, rowIndex, colIndex }) {
  toast.show(`Current selection: ${item.title}, row index: ${rowIndex}, column index: ${colIndex}`)
}

Component State ​

Option States ​

Can set color, disabled, loading and other states.

html
<wd-button @click="showActions">Show Menu</wd-button>
<wd-action-sheet v-model="show" :actions="actions" @close="close" />
typescript
const show = ref<boolean>(false)
const actions = ref([
  {
    name: 'Color',
    color: '#0083ff'
  },
  {
    name: 'Disabled',
    disabled: true
  },
  {
    loading: true
  }
])
function showActions() {
  show.value = true
}

function close() {
  show.value = false
}

Component Variant ​

Cancel Button ​

Set cancel-text to display cancel button text.

html
<wd-action-sheet v-model="show" :actions="actions" @close="close" cancel-text="Cancel" />

Title ​

Set title to display title.

html
<wd-action-sheet v-model="show" title="Title" @close="close">
  <view style="padding: 15px 15px 150px 15px;">Content</view>
</wd-action-sheet>

Attributes ​

ParameterDescriptionTypeDefault Value
v-modelControl menu show/hidebooleanfalse
actionsMenu options, see Action data structure belowAction[][]
panelsCustom grid panel items, supports one-dimensional Panel[] and two-dimensional Panel[][] (multi-row)Array<Panel | Panel[]>[]
titleTitlestring-
cancel-textCancel button textstring-
close-on-click-actionWhether to close menu after clicking optionbooleantrue
close-on-click-modalWhether to close when clicking maskbooleantrue
durationAnimation duration (ms)number200
z-indexMenu z-indexnumber10
lazy-renderLazy render popup content, only render when triggered to showbooleantrue
safe-area-inset-bottomWhether popup panel sets bottom safe distance (iPhone X type devices)booleantrue
root-portalWhether to detach from page (H5: teleport, App: renderjs, Mini Program: root-portal)booleanfalse
custom-title-classTitle area custom class namestring-
custom-classRoot node custom class namestring-
custom-styleRoot node custom stylestring-

Events ​

Event NameDescriptionParameters
selectTriggered when clicking optionMenu options or custom panel one-dimensional array: { item, index }; Custom panel two-dimensional array: { item, rowIndex, colIndex }
enterTriggered when open animation starts-
after-enterTriggered when open animation ends-
leaveTriggered when close animation starts-
after-leaveTriggered when close animation ends-
closeTriggered when panel closes-
click-modalTriggered when clicking mask-
cancelTriggered when clicking cancel button-

Action Data Structure ​

KeyDescriptionType
nameOption namestring
descriptionDescription infostring
colorColorstring
disabledDisabledboolean
loadingLoading stateboolean

Panel Data Structure ​

KeyDescriptionType
iconIcon name or image URLstring
titleTitle contentstring

Slots ​

nameDescriptionParameters
defaultCustom content area, will override default actions/panels rendering when passed-
closeCustom title bar right close area{ close }

主题定制 ​

CSS 变量 ​

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置。

名称默认值描述
--wot-action-sheet-bg$filled-oppo底部弹层背景色
--wot-action-sheet-radius$radius-large底部弹层圆角
--wot-action-sheet-action-bg$filled-oppo操作项背景色
--wot-action-sheet-action-font-size$typography-title-size-main操作项字体大小
--wot-action-sheet-action-line-height$typography-title-line-height-size-main操作项行高
--wot-action-sheet-action-color$text-main操作项文字颜色
--wot-action-sheet-action-padding$padding-extra-loose $padding-loose操作项内边距
--wot-action-sheet-gap-bg$filled-bottom取消按钮与操作项的间隔背景色
--wot-action-sheet-cancel-bg$filled-oppo取消按钮背景色
--wot-action-sheet-cancel-font-size$typography-title-size-main取消按钮字体大小
--wot-action-sheet-cancel-line-height$typography-title-line-height-size-main取消按钮行高
--wot-action-sheet-cancel-color$text-main取消按钮文字颜色
--wot-action-sheet-cancel-padding$padding-extra-loose $padding-loose取消按钮内边距
--wot-action-sheet-gap-height$spacing-tight取消按钮顶部外边距
--wot-action-sheet-description-font-size$typography-body-size-main描述文本字体大小
--wot-action-sheet-description-line-height$typography-body-line-height-size-main描述文本行高
--wot-action-sheet-description-color$text-auxiliary描述文本颜色
--wot-action-sheet-description-margin-top$spacing-tight描述文本顶部外边距
--wot-action-sheet-panel-bg$filled-oppo面板区域背景色
--wot-action-sheet-panels-wrap-padding$padding-main $padding-zero面板容器内边距
--wot-action-sheet-panels-padding$padding-zero $padding-main面板列表内边距
--wot-action-sheet-panel-width$n-88单个面板宽度
--wot-action-sheet-panel-padding$padding-main $padding-zero单个面板内边距
--wot-action-sheet-panel-img-size$n-24面板图片尺寸
--wot-action-sheet-panel-img-spacing$spacing-zero auto $spacing-tight面板图片外边距
--wot-action-sheet-panel-img-radius$radius-main面板图片圆角
--wot-action-sheet-panel-title-font-size$typography-label-size-main面板标题字体大小
--wot-action-sheet-panel-title-line-height$typography-label-line-height-size-main面板标题行高
--wot-action-sheet-panel-title-color$text-auxiliary面板标题颜色
--wot-action-sheet-title-bg$filled-oppo标题背景色
--wot-action-sheet-title-color$text-main标题文字颜色
--wot-action-sheet-title-height$n-56标题区域高度
--wot-action-sheet-title-font-size$typography-title-size-main标题字体大小
--wot-action-sheet-title-line-height$typography-title-line-height-size-main标题行高
--wot-action-sheet-title-font-weight$font-weight-medium标题字重
--wot-action-sheet-close-right$spacing-loose关闭图标右侧偏移
--wot-action-sheet-close-color$icon-secondary关闭图标颜色
--wot-action-sheet-close-font-size$n-24关闭图标尺寸
--wot-action-sheet-active-bg$filled-content激活态背景色
--wot-action-sheet-disabled-color$text-disabled禁用态文字颜色
--wot-action-sheet-loading-size$n-20加载图标尺寸

Source Code ​

Documentation
• Component

Released under the MIT License.

Released under the MIT License.