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 分类选择

Sidebar

Introduction

A vertically displayed navigation bar for switching between different content areas.

Code Demonstration

Basic usage

Bind the index of the currently selected item through v-model.

<z-sidebar v-model="active"> 
  <z-sidebar-item title="tag name" /> 
  <z-sidebar-item title="label name" /> 
  <z-sidebar-item title="tag name" /> 
</z-sidebar>
import { ref } from 'vue'; 
 
export default { 
  setup() { 
    const active = ref(0); 
    return { active }; 
  }, 
};

Disable options

Disable the option with the disabled attribute.

<z-sidebar v-model="active"> 
  <z-sidebar-item title="tag name" /> 
  <z-sidebar-item title="label name" disabled /> 
  <z-sidebar-item title="label name" /> 
</z-sidebar>

Listening to Switch Events

Set the change method to listen for events when switching navigation items.

<z-sidebar v-model="active" @change="onChange"> 
  <z-sidebar-item title="Tag name 1" /> 
  <z-sidebar-item title="label name 2" /> 
  <z-sidebar-item title="Tag name 3" /> 
</z-sidebar>
import { ref } from 'vue'; 
import { useToast } from '@/uni_modules/zebra-ui' 
const toast = useToast() 
 
export default { 
  setup() { 
    const active = ref(0); 
    const onChange = (index: number) => toast.showToast(`Title ${index + 1}`) 
    return { 
      active, 
      onChange, 
    }; 
  }, 
};

Logo tips

After setting the dot property, a small red dot will be displayed in the upper right corner; After setting the badge property, the corresponding logo will be displayed in the upper right corner.

<z-sidebar v-model="active"> 
  <z-sidebar-item title="label name" dot /> 
  <z-sidebar-item title="label name" badge="5" /> 
  <z-sidebar-item title="tag name" /> 
</z-sidebar>

API

Sidebar Props

ParameterDescriptionTypeDefault Value
v-modelIndex of the current navigation itemnumber | string0

Sidebar Events

Event NameDescriptionCallback Parameter
changeTriggered when switching navigation itemsindex: number

SidebarItem Props

ParameterDescriptionTypeDefault Value
titlecontentstring''
dotWhether to display the small red dot in the upper right cornerbooleanfalse
badgeThe content of the logo in the upper right corner of the iconnumber | string-
badge-propsCustomize the attributes of the badge. The passed-in object will be passed through to the Badge component propsBadgeProps-
disabledWhether to disable the itembooleanfalse

SidebarItem Events

Event NameDescriptionCallback Parameter
clickTriggered when clickedindex: number

SidebarItem Slots

NameDescription
titleCustomize Title

Theme customization

Style Variables

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

NameDefault ValueDescription
--z-sidebar-width160rpx-
--z-sidebar-font-sizevar(--z-font-size-md)-
--z-sidebar-line-heightvar(--z-line-height-md)-
--z-sidebar-text-colorvar(--z-text-color)-
--z-sidebar-disabled-text-colorvar(--z-text-color-3)-
--z-sidebar-padding40rpx var(--z-padding-sm)-
--z-sidebar-active-colorvar(--z-active-color)-
--z-sidebar-backgroundvar(--z-background)-
--z-sidebar-selected-font-weightvar(--z-font-bold)-
--z-sidebar-selected-text-colorvar(--z-text-color)-
--z-sidebar-selected-border-width8rpx-
--z-sidebar-selected-border-height32rpx-
--z-sidebar-selected-border-colorvar(--z-primary-color)-
--z-sidebar-selected-backgroundvar(--z-background-2)-