zebra-ui基于uniapp,跨多端组件库
  • 2.x
  • 中文
开发指南
介绍
快速上手
进阶用法
常见问题
更新日志
贡献指南
国际化
基础组件
Button 按钮
Cell 单元格
ConfigProvider 全局配置
Icon 图标
Image 图片
Layout 布局
Popup 弹出层
Style 内置样式
Transition 动画
Toast 轻提示
表单组件
Area 省市区选择
Calendar 日历
Cascader 级联选择
Checkbox 复选框
DatePicker 日期选择
Field 输入框
Form 表单
NumberKeyboard 数字键盘
PasswordInput 密码输入框
Picker 选择器
PickerGroup 选择器组
Radio 单选框
Rate 评分
Search 搜索
Slider 滑块
Signature 签名
Stepper 步进器
Switch 开关
TimePicker 时间选择
Uploader 文件上传
反馈组件
ActionSheet 动作面板
Barrage 弹幕
Dialog 弹出框
DropdownMenu 下拉菜单
FloatingPanel 浮动面板
FloatingBubble 浮动气泡
Loading 加载
Notify 消息通知
Overlay 遮罩层
PullRefresh 下拉刷新
ShareSheet 分享面板
SwipeCell 滑动单元格
展示组件
Badge 徽标
Circle 环形进度条
Collapse 折叠面板
CountDown 倒计时
Divider 分割线
Empty 空状态
Highlight 高亮文本
List 列表
NoticeBar 通知栏
Popover 气泡弹出框
Progress 进度条
RollingText 翻滚文本
Skeleton 骨架屏
Steps 步骤条
Sticky 粘性布局
Swipe 轮播
Tag 标签
TextEllipsis 文本省略
Watermark 水印
导航组件
Grid 宫格
NavBar 导航栏
Sidebar 侧边导航
Tab 标签页
Tabbar 标签栏
TreeSelect 分类选择

ShareSheet sharing panel

introduce

The sharing panel that pops up at the bottom is used to display the operation buttons corresponding to each sharing channel, without specific sharing logic.

Code Demo

Basic usage

The sharing panel defines sharing options through the options attribute. Each item in the array is an object. For the object format, see the table at the bottom of the document.

<z-cell is-link title="Show sharing panel" @click="showBasic = true" />
<z-share-sheet
   v-model:show="showBasic"
   title="Share with friends now"
   :options="options"
   @select="onSelect"
/>
import { useToast } from '../../uni_modules/zebra-ui'
const toast = useToast()
const showBasic = ref(false)
const options = computed(() => [
   { name: 'WeChat', icon: 'wechat' },
   { name: 'Weibo', icon: 'weibo' },
   { name: 'Copy link', icon: 'link' },
   { name: 'Share poster', icon: 'poster' },
   { name: 'QR code', icon: 'qrcode' }
])
const onSelect = (option: any) => {
   toast.showToast(option.name)
   showBasic.value = false
}

Show multi-line options

When the number of sharing options is large, options can be defined as a nested array format, and each sub-array will be displayed as a row of options.

<z-share-sheet
   v-model:show="showMultiLine"
   title="Share with friends now"
   :options="multiLineOptions"
   @select="onSelect"
/>
const multiLineOptions = computed(() => [
   [
     { name: 'WeChat', icon: 'wechat' },
     { name: 'Moments', icon: 'wechat-moments' },
     { name: 'Weibo', icon: 'weibo' },
     { name: 'QQ', icon: 'qq' }
   ],
   [
     { name: 'Copy link', icon: 'link' },
     { name: 'Share poster', icon: 'poster' },
     { name: 'QR code', icon: 'qrcode' },
     { name: 'small program code', icon: 'weapp-qrcode' }
   ]
])

Custom icon

In addition to using several built-in icons, you can directly pass the image URL in icon to use a custom icon.

<z-share-sheet
   v-model:show="showCustomIcon"
   :options="customIconOptions"
   @select="onSelect"
/>
const customIconOptions = computed(() => [
   {
     name: 'name',
     icon: 'https://cdn.zebraui.com/zebra-ui/images/assets/demo-select.png'
   },
   {
     name: 'name',
     icon: 'zhihu'
   },
   {
     name: 'name',
     icon: 'linkedin'
   },
   { name: 'name', icon: 'facebook' }
])

Display description information

The description text under the title can be set through the description attribute, and the description of the sharing options can be added by setting the description attribute in options.

<z-share-sheet
   v-model:show="showWithDesc"
   title="Share with friends now"
   :options="optionsWithDesc"
   description="Description information"
   @select="onSelect"
/>
const optionsWithDesc = computed(() => [
   { name: 'WeChat', icon: 'wechat' },
   { name: 'Weibo', icon: 'weibo' },
   {
     name: 'Copy link',
     icon: 'link',
     description: 'Description information'
   },
   { name: 'Share poster', icon: 'poster' },
   { name: 'QR code', icon: 'qrcode' }
])

API

Props

ParametersDescriptionTypeDefault value
v-model:showWhether to display the sharing panelbooleanfalse
optionsSharing optionsOption[]
titletop titlestring-
cancel-textCancel button text, passing an empty string can hide the buttonstring'Cancel'
descriptionAuxiliary description text below the titlestring-
durationanimation duration in milliseconds, set to 0 to disable animationnumber | string300
z-indexSet the z-index level of the panel to a fixed valuenumber | string2000+
roundWhether to display rounded cornersbooleantrue
overlaywhether to display the mask layerbooleantrue
overlay-classCustom mask layer class namestring | Array | object-
overlay-styleCustom mask layer styleobject-
lock-scrollWhether to lock background scrollingbooleantrue
close-on-popstateWhether to automatically close when the page is rolled backbooleantrue
close-on-click-overlayWhether to close the overlay after clicking itbooleantrue
safe-area-inset-bottomWhether to enable bottom safe area adaptationbooleantrue
before-closeCallback function before closing, return false to prevent closing, support returning Promise(action: string) => boolean | Promise<boolean>-

Option data structure

The options property is an array of objects. Each object in the array is configured with a column. The objects can contain the following values:

Key nameDescriptionType
nameSharing channel namestring
descriptionDescription of sharing optionsstring
iconIcon, optional values are wechat weibo qq link qrcode poster weapp-qrcode wechat-moments, supports passing in image URLstring
classNameSharing option class namestring

Events

Event nameDescriptionCallback parameters
selectTriggered when the sharing option is clickedoption: Option, index: number
cancelTriggered when the cancel button is clicked-
openTriggered when the panel is opened-
closeTriggered when closing the panel-
openedTriggered after the panel is opened and the animation ends-
closedTriggered after the panel is closed and the animation ends-
click-overlayTriggered when the overlay layer is clickedevent: MouseEvent

Slots

NameDescription
titleCustom top title
descriptionCustom description text
cancelCustomize cancel button content

Theme customization

Style variables

The component provides the following CSS variables, which can be used to customize styles. For usage, please refer to ConfigProvider component.

NameDefaultDescription
--z-share-sheet-header-paddingvar(--z-padding-sm) var(--z-padding-md) var(--z-padding-base)-
--z-share-sheet-title-colorvar(--z-text-color)-
--z-share-sheet-title-font-sizevar(--z-font-size-md)-
--z-share-sheet-title-line-heightvar(--z-line-height-md)-
--z-share-sheet-description-colorvar(--z-text-color-2)-
--z-share-sheet-description-font-sizevar(--z-font-size-sm)-
--z-share-sheet-description-line-height32rpx-
--z-share-sheet-icon-size96rpx-
--z-share-sheet-option-name-colorvar(--z-gray-7)-
--z-share-sheet-option-name-font-sizevar(--z-font-size-sm)-
--z-share-sheet-option-description-colorvar(--z-text-color-3)-
--z-share-sheet-option-description-font-sizevar(--z-font-size-sm)-
--z-share-sheet-cancel-button-font-sizevar(--z-font-size-lg)-
--z-share-sheet-cancel-button-height96rpx-
--z-share-sheet-cancel-button-backgroundvar(--z-background-2)-