/*! For license information please see 4788.ccf7d4bb.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["4788"],{75030:function(n,s,t){"use strict";t.r(s);var a=t("80681");let e=["innerHTML"];s.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
The pop-up modal panel at the bottom contains multiple options related to the current situation.
\nRegister component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { ActionSheet } from 'vant';\n\nconst app = createApp();\napp.use(ActionSheet);\n
\nUse actions
prop to set options of action-sheet.
<van-cell is-link title="Basic Usage" @click="show = true" />\n<van-action-sheet v-model:show="show" :actions="actions" @select="onSelect" />\n
\nimport { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n setup() {\n const show = ref(false);\n const actions = [\n { name: 'Option 1' },\n { name: 'Option 2' },\n { name: 'Option 3' },\n ];\n const onSelect = (item) => {\n show.value = false;\n showToast(item.name);\n };\n\n return {\n show,\n actions,\n onSelect,\n };\n },\n};\n
\nUse the icon
field of actions
to set the icon for the option.
<van-cell is-link title="Show Icon" @click="show = true" />\n<van-action-sheet v-model:show="show" :actions="actions" @select="onSelect" />\n
\nimport { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n setup() {\n const show = ref(false);\n const actions = [\n { name: 'Option 1', icon: 'cart-o' },\n { name: 'Option 2', icon: 'shop-o' },\n { name: 'Option 3', icon: 'star-o' },\n ];\n const onSelect = (item) => {\n show.value = false;\n showToast(item.name);\n };\n\n return {\n show,\n actions,\n onSelect,\n };\n },\n};\n
\n<van-action-sheet\n v-model:show="show"\n :actions="actions"\n cancel-text="Cancel"\n close-on-click-action\n @cancel="onCancel"\n/>\n
\nimport { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n setup() {\n const show = ref(false);\n const actions = [\n { name: 'Option 1' },\n { name: 'Option 2' },\n { name: 'Option 3' },\n ];\n const onCancel = () => showToast('cancel');\n\n return {\n show,\n actions,\n onCancel,\n };\n },\n};\n
\n<van-action-sheet\n v-model:show="show"\n :actions="actions"\n cancel-text="Cancel"\n description="Description"\n close-on-click-action\n/>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const show = ref(false);\n const actions = [\n { name: 'Option 1' },\n { name: 'Option 2' },\n { name: 'Option 3', subname: 'Description' },\n ];\n\n return {\n show,\n actions,\n };\n },\n};\n
\n<van-action-sheet\n v-model:show="show"\n :actions="actions"\n cancel-text="Cancel"\n close-on-click-action\n/>\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const show = ref(false);\n const actions = [\n { name: 'Colored Option', color: '#ee0a24' },\n { name: 'Disabled Option', disabled: true },\n { name: 'Loading Option', loading: true },\n ];\n\n return {\n show,\n actions,\n };\n },\n};\n
\n<van-action-sheet v-model:show="show" title="Title">\n <div class="content">Content</div>\n</van-action-sheet>\n\n<style>\n .content {\n padding: 16px 16px 160px;\n }\n</style>\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
v-model:show | \nWhether to show ActionSheet | \nboolean | \nfalse | \n
actions | \nOptions | \nActionSheetAction[] | \n[] | \n
title | \nTitle | \nstring | \n- | \n
cancel-text | \nText of cancel button | \nstring | \n- | \n
description | \nDescription above the options | \nstring | \n- | \n
closeable | \nWhether to show close icon | \nboolean | \ntrue | \n
close-icon | \nClose icon name | \nstring | \ncross | \n
duration | \nTransition duration, unit second | \nnumber | string | \n0.3 | \n
z-index | \nSet the z-index to a fixed value | \nnumber | string | \n2000+ | \n
round | \nWhether to show round corner | \nboolean | \ntrue | \n
overlay | \nWhether to show overlay | \nboolean | \ntrue | \n
overlay-class | \nCustom overlay class | \nstring | Array | object | \n- | \n
overlay-style | \nCustom overlay style | \nobject | \n- | \n
lock-scroll | \nWhether to lock background scroll | \nboolean | \ntrue | \n
lazy-render | \nWhether to lazy render util appeared | \nboolean | \ntrue | \n
close-on-popstate | \nWhether to close when popstate | \nboolean | \ntrue | \n
close-on-click-action | \nWhether to close when an action is clicked | \nboolean | \nfalse | \n
close-on-click-overlay | \nWhether to close when overlay is clicked | \nboolean | \ntrue | \n
safe-area-inset-bottom | \nWhether to enable bottom safe area adaptation | \nboolean | \ntrue | \n
teleport | \nSpecifies a target element where ActionSheet will be mounted | \nstring | Element | \n- | \n
before-close | \nCallback function before close | \n(action: string) => boolean | Promise<boolean> | \n- | \n
Key | \nDescription | \nType | \n
---|---|---|
name | \nTitle | \nstring | \n
subname | \nSubtitle | \nstring | \n
color | \nText color | \nstring | \n
icon v4.8.6 | \nIcon name or URL | \nstring | \n
className | \nclassName for the option | \nstring | Array | object | \n
loading | \nWhether to be loading status | \nboolean | \n
disabled | \nWhether to be disabled | \nboolean | \n
callback | \nCallback function after clicked | \naction: ActionSheetAction | \n
Event | \nDescription | \nArguments | \n
---|---|---|
select | \nEmitted when an option is clicked | \naction: ActionSheetAction, index: number | \n
cancel | \nEmitted when the cancel button is clicked | \n- | \n
open | \nEmitted when opening ActionSheet | \n- | \n
close | \nEmitted when closing ActionSheet | \n- | \n
opened | \nEmitted when ActionSheet is opened | \n- | \n
closed | \nEmitted when ActionSheet is closed | \n- | \n
click-overlay | \nEmitted when overlay is clicked | \nevent: MouseEvent | \n
Name | \nDescription | \nSlotProps | \n
---|---|---|
default | \nCustom content | \n\n |
description | \nCustom description above the options | \n\n |
cancel | \nCustom the content of cancel button | \n\n |
action | \nCustom the content of action | \n{ action: ActionSheetAction, index: number } | \n
The component exports the following type definitions:
\nimport type { ActionSheetProps, ActionSheetAction } from 'vant';\n
\nThe component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-action-sheet-max-height | \n80% | \n- | \n
--van-action-sheet-header-height | \n48px | \n- | \n
--van-action-sheet-header-font-size | \nvar(--van-font-size-lg) | \n- | \n
--van-action-sheet-description-color | \nvar(--van-text-color-2) | \n- | \n
--van-action-sheet-description-font-size | \nvar(--van-font-size-md) | \n- | \n
--van-action-sheet-description-line-height | \nvar(--van-line-height-md) | \n- | \n
--van-action-sheet-item-background | \nvar(--van-background-2) | \n- | \n
--van-action-sheet-item-font-size | \nvar(--van-font-size-lg) | \n- | \n
--van-action-sheet-item-line-height | \nvar(--van-line-height-lg) | \n- | \n
--van-action-sheet-item-text-color | \nvar(--van-text-color) | \n- | \n
--van-action-sheet-item-disabled-text-color | \nvar(--van-text-color-3) | \n- | \n
--van-action-sheet-item-icon-size | \n18px | \n- | \n
--van-action-sheet-item-icon-margin-right | \nvar(--van-padding-xs) | \n- | \n
--van-action-sheet-subname-color | \nvar(--van-text-color-2) | \n- | \n
--van-action-sheet-subname-font-size | \nvar(--van-font-size-sm) | \n- | \n
--van-action-sheet-subname-line-height | \nvar(--van-line-height-sm) | \n- | \n
--van-action-sheet-close-icon-size | \n22px | \n- | \n
--van-action-sheet-close-icon-color | \nvar(--van-gray-5) | \n- | \n
--van-action-sheet-close-icon-padding | \n0 var(--van-padding-md) | \n- | \n
--van-action-sheet-cancel-text-color | \nvar(--van-gray-7) | \n- | \n
--van-action-sheet-cancel-padding-top | \nvar(--van-padding-xs) | \n- | \n
--van-action-sheet-cancel-padding-color | \nvar(--van-background) | \n- | \n
--van-action-sheet-loading-icon-size | \n22px | \n- | \n