Installation

npm Install

# npm
npm install svelte-mobile-ui

# cnpm(国内镜像)
cnpm install svelte-mobile-ui

# yarn
yarn add svelte-mobile-ui

# pnpm
pnpm add svelte-mobile-ui

Peer Dependencies

Make sure the following dependencies are installed:

npm install svelte

Full Import

// main.ts — 全量导入样式
import 'svelte-mobile-ui/dist/styles.css'

// 组件中使用
import { Button, Cell, Field, Dialog, Tabs } from 'svelte-mobile-ui'

On-demand Import

// 按需导入单个组件(推荐)
import Button from 'svelte-mobile-ui/components/Button/Button.svelte'
import Cell from 'svelte-mobile-ui/components/Cell/Cell.svelte'

// 按需导入样式
import 'svelte-mobile-ui/styles/var.scss'
import 'svelte-mobile-ui/styles/index.scss'

CDN Usage

You can also use it directly via CDN (for quick prototyping or online demos):

<!-- CSS -->
<link rel="stylesheet" href="https://unpkg.com/svelte-mobile-ui@1.2.0/dist/styles.css" />

<!-- JS (IIFE) -->
<script src="https://unpkg.com/svelte-mobile-ui@1.2.0/dist/svelte-mobile-ui.iife.js"></script>

CommonJS Require

const { Button, Cell, Field } = require('svelte-mobile-ui')

Basic

Button

View Code
<Button type="primary">主要按钮</Button>
<Button type="success">成功按钮</Button>
<Button type="warning">警告按钮</Button>
<Button type="danger">危险按钮</Button>
<Button type="default">默认按钮</Button>

<Button type="primary" plain>朴素按钮</Button>
<Button type="primary" round>圆形按钮</Button>
<Button type="primary" size="small">小按钮</Button>
<Button type="primary" size="mini">迷你</Button>

<Button type="primary" disabled>禁用按钮</Button>
<Button type="primary" loading>加载中</Button>
<Button type="primary" icon="plus">带图标</Button>

<Button type="primary" block>块级按钮</Button>

Props

PropertyDescriptionTypeDefault
typeType'default' | 'primary' | 'success' | 'warning' | 'danger''default'
sizeSize'large' | 'normal' | 'small' | 'mini''normal'
textButton textstring''
iconLeft icon namestring''
colorButton colorstring''
blockWhether block elementbooleanfalse
plainWhether plain buttonbooleanfalse
roundWhether round buttonbooleanfalse
squareWhether square buttonbooleanfalse
loadingWhether to show loadingbooleanfalse
loadingTextLoading tip textstring''
loadingSizeLoading icon sizestring'20px'
loadingTypeLoading icon type'circular' | 'spinner''circular'
disabledWhether disabledbooleanfalse
hairlineWhether hairline borderbooleanfalse
iconPositionIcon position'left' | 'right''left'
nativeTypeNative type attribute'button' | 'submit' | 'reset''button'
onclickClick callback(e: MouseEvent) => void-

Cell

Cell
Content
Cell
Description
Content
Show Arrow
With Icon
Content
Required
Content
View Code
<Cell title="单元格" value="内容" />
<Cell title="单元格" value="内容" label="描述信息" />
<Cell title="展示箭头" isLink />
<Cell title="有图标" icon="location-o" value="内容" isLink />
<Cell title="必填" value="内容" required />

Props

PropertyDescriptionTypeDefault
titleLeft titlestring''
valueRight contentstring | number''
labelDescription below titlestring''
iconLeft icon namestring''
sizeSize'' | 'large'''
borderWhether to show bottom borderbooleantrue
centerWhether to vertically center contentbooleanfalse
isLinkWhether to show right arrow with click feedbackbooleanfalse
requiredWhether to show required asteriskbooleanfalse
arrowDirectionArrow direction'up' | 'down' | 'left' | 'right''right'
clickableWhether to enable click feedbackboolean | nullfalse
titleClassTitle extra classstring''
valueClassValue extra classstring''
labelClassLabel extra classstring''
onclickClick callback(e: MouseEvent) => void-

Icon

arrow
arrow-left
arrow-up
arrow-down
success
fail
plus
minus
cross
search
star
star-o
like
like-o
phone
setting
home
cart
user
chat
location
delete
close
edit
eye
share
warning
info
question
View Code
<Icon name="success" size="24" />
<Icon name="star" size="24" color="#ee0a24" />
<Icon name="search" size="32" />

<!-- 所有可用图标 -->
arrow, arrow-left, arrow-up, arrow-down,
success, fail, plus, minus, cross,
search, star, star-o, like, like-o,
phone, setting, home, cart, user,
chat, location, delete, close, edit,
eye, share, warning, info, question ...

Props

PropertyDescriptionTypeDefault
nameIcon name or image URLstring''
sizeIcon sizestring | number''
colorIcon colorstring''
dotWhether to show red dotbooleanfalse
badgeBadge contentstring | number''
classPrefixClass prefixstring'smu-icon'
onclickClick callback(e: MouseEvent) => void-

Image

View Code
<ImageComp src="..." width="100" height="100" radius={8} />
<ImageComp src="..." width="100" height="100" round />
<ImageComp src="..." width="100" height="100" fit="cover" />

Props

PropertyDescriptionTypeDefault
srcImage URLstring''
altAlt textstring''
fitFit mode'contain' | 'cover' | 'fill' | 'none' | 'scale-down''fill'
widthWidthstring | number''
heightHeightstring | number''
radiusBorder radiusstring | number0
roundWhether round imagebooleanfalse
lazyLoadWhether to enable lazy loadingbooleanfalse
showErrorWhether to show error placeholderbooleantrue
showLoadingWhether to show loading placeholderbooleantrue
errorIconError iconstring'photo'
loadingIconLoading iconstring''
onclickClick callback(e: MouseEvent) => void-

Popup

Center Popup
Bottom Popup
View Code
<Popup bind:show={showPopup} position="center" closeable>
  <div style="padding: 40px">居中弹窗内容</div>
</Popup>

<Popup bind:show={showPopupBottom} position="bottom" round closeable>
  <div style="padding: 40px">底部弹窗内容</div>
</Popup>

Props

PropertyDescriptionTypeDefault
showWhether to show popupbooleanfalse
positionPopup position'top' | 'bottom' | 'left' | 'right' | 'center''center'
roundWhether to show round cornersbooleanfalse
closeableWhether to show close buttonbooleanfalse
closeIconClose icon namestring'cross'
closeIconPositionClose icon position'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''top-right'
overlayWhether to show overlaybooleantrue
lockScrollWhether to lock background scrollbooleantrue
durationAnimation duration (s)number0.3
safeAreaInsetBottomWhether to adapt bottom safe areabooleanfalse
safeAreaInsetTopWhether to adapt top safe areabooleanfalse
zIndexZ-indexnumber2000
oncloseClose callback() => void-

Toast

Text Toast
Loading Toast
Success Toast
Fail Toast
View Code
<Toast bind:show type="text" message="提示内容" />
<Toast bind:show type="loading" message="加载中..." />
<Toast bind:show type="success" message="成功" />
<Toast bind:show type="fail" message="失败" />

Props

PropertyDescriptionTypeDefault
showWhether to showbooleanfalse
typeToast type'text' | 'loading' | 'success' | 'fail' | 'html''text'
messageToast messagestring | number''
iconCustom iconstring''
positionPopup position'top' | 'middle' | 'bottom''middle'
durationDisplay duration (ms), 0 means no auto closenumber2000
overlayWhether to show overlaybooleanfalse
forbidClickWhether to disable background clickbooleanfalse
closeOnClickWhether to close on clickbooleanfalse
closeOnClickOverlayWhether to close on overlay clickbooleanfalse
zIndexZ-indexnumber2010

Loading

Loading...
View Code
<Loading />
<Loading type="spinner" />
<Loading color="#1989fa" />
<Loading size="24" />
<Loading vertical>加载中...</Loading>

Props

PropertyDescriptionTypeDefault
typeLoading icon type'circular' | 'spinner''circular'
colorColorstring''
sizeLoading icon sizestring | number'30px'
verticalWhether to arrange icon and text verticallybooleanfalse
textSizeText sizestring''
textColorText colorstring''

Form

Field

Text
Password
Phone
Message
Error
Please enter valid content
View Code
<Field bind:value label="文本" placeholder="请输入文本" />
<Field label="密码" type="password" placeholder="请输入密码" />
<Field label="手机号" type="tel" placeholder="请输入手机号" />
<Field label="留言" type="textarea" placeholder="请输入留言" rows={3} />
<Field label="错误提示" error errorMessage="请输入正确的内容" />

Props

PropertyDescriptionTypeDefault
valueInput valuestring | number''
typeInput type'text' | 'tel' | 'url' | 'email' | 'number' | 'password' | 'textarea' | 'digit''text'
labelLeft label textstring''
nameForm identifierstring''
placeholderPlaceholder textstring''
disabledWhether disabledbooleanfalse
readonlyWhether readonlybooleanfalse
requiredWhether to show required asteriskbooleanfalse
clearableWhether to enable clear buttonbooleanfalse
clearIconClear icon namestring'clear'
clearTriggerWhen to show clear icon'focus' | 'always''focus'
maxlengthMax length, -1 for unlimitednumber-1
showWordLimitWhether to show word countbooleanfalse
errorWhether to mark input as errorbooleanfalse
errorMessageBottom error messagestring''
errorMessageAlignError message alignment'left' | 'center' | 'right''left'
labelWidthLeft label widthstring'6.2em'
labelAlignLabel alignment'left' | 'center' | 'right' | 'top''left'
inputAlignInput content alignmentstring''
autosizeTextarea auto heightboolean | { maxHeight, minHeight }false
leftIconLeft iconstring''
rightIconRight iconstring''
rowsTextarea rowsnumber0
borderWhether to show bottom borderbooleantrue
sizeSize'' | 'large'''
centerWhether to vertically centerbooleanfalse
colonWhether to add colon after labelbooleanfalse
formatterInput formatter function(value: string) => string-
onInputInput callback(value: string) => void-
onFocusFocus callback(e: FocusEvent) => void-
onBlurBlur callback(e: FocusEvent) => void-
onclickClick callback(e: MouseEvent) => void-
onclickInputClick input area callback(e: MouseEvent) => void-
onclickLeftIconClick left icon callback(e: MouseEvent) => void-
onclickRightIconClick right icon callback(e: MouseEvent) => void-

Switch

Basic Usage
Disabled
Custom Color
Custom Size
View Code
<Switch bind:checked />
<Switch checked disabled />
<Switch checked activeColor="#ee0a24" />
<Switch checked size="20px" />

Props

PropertyDescriptionTypeDefault
checkedSwitch checked stateboolean | anyfalse
loadingWhether loadingbooleanfalse
disabledWhether disabledbooleanfalse
sizeSwitch sizestring | number'26px'
activeColorActive background colorstring''
inactiveColorInactive background colorstring''
activeValueActive valueanytrue
inactiveValueInactive valueanyfalse
onChangeToggle callback(val: any) => void-

Checkbox

View Code
<Checkbox bind:checked>复选框</Checkbox>
<Checkbox checked disabled>禁用</Checkbox>
<Checkbox checked shape="square">方形</Checkbox>
<Checkbox checked checkedColor="#ee0a24">自定义颜色</Checkbox>

Props

PropertyDescriptionTypeDefault
checkedWhether checkedbooleanfalse
disabledWhether disabledbooleanfalse
shapeShape'round' | 'square''round'
iconSizeIcon sizestring'20px'
checkedColorChecked colorstring''
labelPositionLabel position'left' | 'right''right'
labelDisabledWhether to disable label clickbooleanfalse
nameIdentifierstring''
onChangeChange callback(checked: boolean) => void-

Radio

View Code
<Radio bind:checked>单选框</Radio>
<Radio checked disabled>禁用</Radio>
<Radio checked shape="dot">圆点样式</Radio>

Props

PropertyDescriptionTypeDefault
checkedWhether checkedbooleanfalse
disabledWhether disabledbooleanfalse
shapeShape'round' | 'square' | 'dot''round'
iconSizeIcon sizestring'20px'
checkedColorChecked colorstring''
labelPositionLabel position'left' | 'right''right'
labelDisabledWhether to disable label clickbooleanfalse
nameIdentifierstring''
onclickClick callback() => void-

Stepper

Basic Usage
Step 2
Range 5~10
Disabled
Round Style
View Code
<Stepper bind:value />
<Stepper value={1} step={2} />
<Stepper value={5} min={5} max={10} />
<Stepper value={1} disabled />
<Stepper value={1} theme="round" />

Props

PropertyDescriptionTypeDefault
valueCurrent valuenumber1
minMin valuenumber1
maxMax valuenumberInfinity
stepStepnumber1
themeTheme style'' | 'round'''
integerWhether to allow integer onlybooleanfalse
disabledWhether disabledbooleanfalse
disablePlusWhether to disable plus buttonbooleanfalse
disableMinusWhether to disable minus buttonbooleanfalse
disableInputWhether to disable inputbooleanfalse
showPlusWhether to show plus buttonbooleantrue
showMinusWhether to show minus buttonbooleantrue
showInputWhether to show inputbooleantrue
inputWidthInput widthstring'32px'
buttonSizeButton sizestring'28px'
longPressWhether to enable long pressbooleantrue
placeholderInput placeholderstring''
decimalLengthFixed decimal placesnumber-
onChangeValue change callback(value: number) => void-

Rate

Basic Usage
Custom Color
Half Star
Disabled
View Code
<Rate bind:value />
<Rate value={3} color="#ffd21e" voidColor="#eee" />
<Rate value={2.5} allowHalf />
<Rate value={4} disabled />

Props

PropertyDescriptionTypeDefault
valueCurrent valuenumber0
countTotal iconsnumber5
sizeIcon sizestring'20px'
colorActive colorstring'#ee0a24'
voidColorVoid colorstring'#c8c9cc'
iconActive iconstring'star'
voidIconVoid iconstring'star-o'
allowHalfWhether to allow halfbooleanfalse
disabledWhether disabledbooleanfalse
readonlyWhether readonlybooleanfalse
disabledColorDisabled colorstring'#c8c9cc'
gutterIcon gapstring'4px'
touchableWhether touchable to selectbooleantrue
onChangeValue change callback(value: number) => void-

Slider

View Code
<Slider bind:value />
<Slider value={50} barHeight="4px" activeColor="#ee0a24" />
<Slider value={30} disabled />

Props

PropertyDescriptionTypeDefault
valueCurrent progressnumber0
minMin valuenumber0
maxMax valuenumber100
stepStepnumber1
disabledWhether disabledbooleanfalse
readonlyWhether readonlybooleanfalse
barHeightBar heightstring'2px'
buttonSizeSlider button sizestring'24px'
activeColorActive colorstring''
inactiveColorInactive colorstring''
verticalWhether verticalbooleanfalse
onChangeProgress change callback(value: number) => void-

Display

Tag

Default Primary Success Warning Danger
Plain Round Mark Medium Large
View Code
<Tag>默认</Tag>
<Tag type="primary">主要</Tag>
<Tag type="success">成功</Tag>
<Tag type="warning">警告</Tag>
<Tag type="danger">危险</Tag>

<Tag type="primary" plain>空心</Tag>
<Tag type="primary" round>圆角</Tag>
<Tag type="primary" mark>标记</Tag>

Props

PropertyDescriptionTypeDefault
typeType'default' | 'primary' | 'success' | 'danger' | 'warning''default'
sizeSize'' | 'large' | 'medium'''
colorTag colorstring''
plainWhether plain stylebooleanfalse
roundWhether round stylebooleanfalse
markWhether mark stylebooleanfalse
textColorText colorstring''
closeableWhether closeablebooleanfalse
showWhether to showbooleantrue
oncloseClose callback() => void-

Badge

5
10
99+
View Code
<Badge content={5}><div>...</div></Badge>
<Badge content={10}><div>...</div></Badge>
<Badge content="99+"><div>...</div></Badge>
<Badge dot><div>...</div></Badge>

Props

PropertyDescriptionTypeDefault
contentBadge contentstring | number''
colorBadge background colorstring''
dotWhether to show as dotbooleanfalse
maxMax value, shows {max}+ when exceedednumber0
showZeroWhether to show when zerobooleantrue
offsetBadge offset[number, number]-

Divider

View Code
<Divider />
<Divider dashed />
<Divider>文字</Divider>
<Divider contentPosition="left">左侧内容</Divider>
<Divider contentPosition="right">右侧内容</Divider>

Props

PropertyDescriptionTypeDefault
dashedWhether dashedbooleanfalse
hairlineWhether hairlinebooleantrue
contentPositionContent position'left' | 'center' | 'right''center'

Empty

No Data

View Code
<Empty description="暂无数据" />
<Empty image="error" description="加载失败" />
<Empty image="network" description="网络错误" />
<Empty image="search" description="搜索为空" />

Props

PropertyDescriptionTypeDefault
imageImage type or custom URL'default' | 'error' | 'network' | 'search' | string'default'
imageSizeImage sizestring | number''
descriptionDescription textstring''

Progress

50%
70%
100%
30%
View Code
<Progress percentage={50} />
<Progress percentage={70} color="#ee0a24" />
<Progress percentage={100} />
<Progress percentage={30} inactive />

Props

PropertyDescriptionTypeDefault
percentageProgress percentagenumber0
strokeWidthStroke widthnumber | string4
colorProgress colorstring''
trackColorTrack colorstring''
pivotTextPivot textstring''
pivotColorPivot background colorstring''
textColorPivot text colorstring''
inactiveWhether inactivebooleanfalse
showPivotWhether to show pivotbooleantrue

NoticeBar

The frequency of swearing during code review is the only standard for measuring code quality.
Technology is the shared soul of its developers.
Welcome to svelte-mobile-ui component library
Please check the latest notifications
View Code
<NoticeBar text="通知内容..." leftIcon="volume" />
<NoticeBar text="可关闭" mode="closeable" />
<NoticeBar text="链接模式" mode="link" />
<NoticeBar text="换行模式" wrapable scrollable={false} />

Props

PropertyDescriptionTypeDefault
textNotice textstring''
modeNoticeBar mode'' | 'closeable' | 'link'''
colorText colorstring''
backgroundBackground colorstring''
leftIconLeft icon namestring''
wrapableWhether wrappablebooleanfalse
scrollableWhether scrollablebooleantrue
delayAnimation delay (s)number1
speedScroll speed (px/s)number60
onclickClick callback(e: MouseEvent) => void-
oncloseClose callback() => void-

Collapse

Title 1
Title 2
Disabled Panel
View Code
<Collapse>
  <CollapseItem title="标题1" bind:isExpanded>
    折叠内容 1
  </CollapseItem>
  <CollapseItem title="标题2" bind:isExpanded>
    折叠内容 2
  </CollapseItem>
  <CollapseItem title="禁用" disabled>
    此面板已禁用
  </CollapseItem>
</Collapse>

Props

PropertyDescriptionTypeDefault
titleTitlestring''
nameUnique identifierstring | number''
iconTitle bar left iconstring''
labelTitle bar descriptionstring''
valueTitle bar right contentstring''
borderWhether to show inner borderbooleantrue
isLinkWhether to show right arrowbooleantrue
disabledWhether disabledbooleanfalse
readonlyWhether readonlybooleanfalse
isExpandedWhether expandedbooleanfalse

Feedback

ActionSheet

Basic Usage
View Code
<ActionSheet
  bind:show
  title="标题"
  cancelText="取消"
  actions={[
    { name: '选项一' },
    { name: '选项二' },
    { name: '选项三', subname: '描述信息' },
  ]}
/>

Props

PropertyDescriptionTypeDefault
showWhether to showbooleanfalse
titleTop titlestring''
descriptionDescription above optionsstring''
cancelTextCancel button textstring''
closeableWhether to show close buttonbooleantrue
closeIconClose icon namestring'cross'
roundWhether to show round cornersbooleantrue
safeAreaInsetBottomWhether to adapt bottom safe areabooleantrue
actionsAction list{ name, subname?, color?, loading?, disabled? }[][]
onSelectSelect callback(action, index) => void-
onCancelCancel callback() => void-
oncloseClose callback() => void-

Dialog

Alert Dialog
View Code
<Dialog
  bind:show
  title="标题"
  message="代码是写出来给人看的,附带能在机器上运行。"
  showCancelButton
/>

Props

PropertyDescriptionTypeDefault
showWhether to showbooleanfalse
titleTitlestring''
messageMessage contentstring''
messageAlignMessage alignment'left' | 'center' | 'right''center'
themeTheme style'default' | 'round-button''default'
showConfirmButtonWhether to show confirm buttonbooleantrue
showCancelButtonWhether to show cancel buttonbooleanfalse
confirmButtonTextConfirm button textstring'确认'
cancelButtonTextCancel button textstring'取消'
confirmButtonColorConfirm button colorstring''
cancelButtonColorCancel button colorstring''
closeOnClickOverlayWhether to close on overlay clickbooleanfalse
widthDialog widthstring'320px'
onConfirmConfirm callback() => void-
onCancelCancel callback() => void-
oncloseClose callback() => void-

Overlay

Show Overlay
View Code
<Overlay show={showOverlay} onclick={() => showOverlay = false} />

Props

PropertyDescriptionTypeDefault
showWhether to showbooleanfalse
zIndexZ-indexnumber1
durationAnimation duration (s)number0.3
lockScrollWhether to lock background scrollbooleantrue
customStyleCustom stylestring''
onclickClick callback(e: MouseEvent) => void-

Navigation

NavBar

Back
Title
Button
View Code
<NavBar
  title="标题"
  leftArrow
  leftText="返回"
  rightText="按钮"
  onclickLeft={() => history.back()}
/>

Props

PropertyDescriptionTypeDefault
titleTitlestring''
leftTextLeft textstring''
rightTextRight textstring''
leftArrowWhether to show left arrowbooleanfalse
borderWhether to show bottom borderbooleantrue
fixedWhether fixed at topbooleanfalse
placeholderWhether to generate placeholder when fixedbooleanfalse
safeAreaInsetTopWhether to adapt top safe areabooleanfalse
zIndexZ-indexnumber1
onclickLeftClick left callback() => void-
onclickRightClick right callback() => void-

Tabs

Current Tab: 1
View Code
<!-- 线性标签 -->
<Tabs bind:active items={[
  { title: '标签一' },
  { title: '标签二' },
  { title: '标签三' },
]}>
  <div>内容</div>
</Tabs>

<!-- 卡片标签 -->
<Tabs active={0} type="card" items={[
  { title: '标签一' },
  { title: '标签二' },
]}/>

Props

PropertyDescriptionTypeDefault
activeCurrent active tab index/namenumber | string0
typeTheme style'line' | 'card''line'
colorTab theme colorstring''
backgroundTab bar background colorstring''
lineWidthBottom line widthnumber | string40
lineHeightBottom line heightnumber | string3
stickyWhether sticky positioningbooleanfalse
animatedWhether to animate tab changebooleanfalse
swipeableWhether swipeablebooleanfalse
scrollspyWhether scroll spybooleanfalse
ellipsisWhether to ellipsis long titlesbooleantrue
shrinkWhether to shrink leftbooleanfalse
itemsTab items data{ title, name?, disabled?, badge?, dot? }[][]
onChangeTab change callback(index: number | string) => void-

Tabbar

Page Content
View Code
<Tabbar>
  <TabbarItem icon="home" isActive>首页</TabbarItem>
  <TabbarItem icon="search">搜索</TabbarItem>
  <TabbarItem icon="chat" badge="3">消息</TabbarItem>
  <TabbarItem icon="user">我的</TabbarItem>
</Tabbar>

Props

PropertyDescriptionTypeDefault
activeCurrent active indexnumber | string0
fixedWhether fixed at bottombooleantrue
borderWhether to show top borderbooleantrue
zIndexZ-indexnumber1
activeColorActive tab colorstring''
inactiveColorInactive tab colorstring''
placeholderWhether to generate placeholder when fixedbooleanfalse
safeAreaInsetBottomWhether to adapt bottom safe areabooleantrue
onChangeTab change callback(active: number | string) => void-

More Components

All components below are implemented. Import via import { Component } from 'svelte-mobile-ui' to use.

Calendar Calendar

Date selection supporting single, multiple, and range modes

View Code
<Calendar bind:show type="single"
  title="选择日期" color="#1989fa"
  minDate={new Date(2024, 0, 1)}
  maxDate={new Date(2025, 11, 31)}
  onConfirm={(date) => console.log(date)} />

Props

PropertyDescriptionTypeDefault
showWhether to show calendar popupbooleanfalse
typeSelection type'single' | 'multiple' | 'range''single'
titleCalendar titlestring'日期选择'
colorTheme colorstring'#1989fa'
minDateMinimum selectable dateDate当天
maxDateMaximum selectable dateDate六个月后
defaultDateDefault selected dateDate | Date[]null
rowHeightRow height of datenumber | string64
poppableWhether to show as popupbooleantrue
showMarkWhether to show month watermarkbooleantrue
showTitleWhether to show calendar titlebooleantrue
showSubtitleWhether to show calendar subtitlebooleantrue
showConfirmWhether to show confirm buttonbooleantrue
readonlyWhether readonlybooleanfalse
confirmTextConfirm button textstring'确定'
confirmDisabledTextText when confirm button is disabledstring'确定'
firstDayOfWeekFirst day of week (0-6)number0
maxRangeMax days for range selectionnumber | string-
onConfirmConfirm button callbackFunction-
oncloseClose popup callbackFunction-

Cascader Cascader

Multi-level data cascading selection

View Code
<Cascader bind:show title="请选择地区"
  options={areaOptions}
  fieldNames={{ text: 'name', value: 'code', children: 'items' }}
  onFinish={(val) => console.log(val)}
  onclose={() => (show = false)} />

Props

PropertyDescriptionTypeDefault
showWhether to showbooleanfalse
titleTop titlestring''
valueSelected valuestring | number-
optionsOptions data sourceCascaderOption[][]
placeholderPlaceholder text when not selectedstring'请选择'
activeColorSelected state colorstring'#1989fa'
closeableWhether to show close iconbooleantrue
closeIconClose icon namestring'cross'
fieldNamesCustom field name mappingobject{ text: 'text', value: 'value', children: 'children' }
onFinishAll options selected callbackFunction-
oncloseClose callbackFunction-
onChangeSelection change callbackFunction-

DatePicker DatePicker

Date picker with year/month/day control

View Code
<DatePicker bind:show title="选择日期"
  columnsType={['year', 'month', 'day']}
  minDate={new Date(2020, 0, 1)}
  maxDate={new Date(2030, 11, 31)}
  onConfirm={(val) => console.log(val)}
  onCancel={() => (show = false)} />

Props

PropertyDescriptionTypeDefault
showWhether to showbooleanfalse
columnsTypeColumns typestring[]['year', 'month', 'day']
minDateMinimum selectable dateDate十年前
maxDateMaximum selectable dateDate十年后
titleTop titlestring''
loadingWhether to show loadingbooleanfalse
readonlyWhether readonlybooleanfalse
filterOptions filter functionFunction-
formatterOptions formatter functionFunction-
confirmButtonTextConfirm button textstring'确认'
cancelButtonTextCancel textstring'取消'
onConfirmConfirm callbackFunction-
onCancelCancel callbackFunction-
onChangeValue change callbackFunction-

TimePicker TimePicker

Time picker with hour/minute/second control

View Code
<TimePicker bind:show title="选择时间"
  columnsType={['hour', 'minute']}
  minHour={8} maxHour={22}
  onConfirm={(val) => console.log(val)}
  onCancel={() => (show = false)} />

Props

PropertyDescriptionTypeDefault
showWhether to showbooleanfalse
columnsTypeColumns typestring[]['hour', 'minute']
minHourMinimum selectable hournumber0
maxHourMaximum selectable hournumber23
minMinuteMinimum selectable minutenumber0
maxMinuteMaximum selectable minutenumber59
titleTop titlestring''
loadingWhether to show loadingbooleanfalse
readonlyWhether readonlybooleanfalse
filterOptions filter functionFunction-
formatterOptions formatter functionFunction-
confirmButtonTextConfirm button textstring'确认'
cancelButtonTextCancel textstring'取消'
onConfirmConfirm callbackFunction-
onCancelCancel callbackFunction-
onChangeValue change callbackFunction-

Picker Picker

General picker with multi-column linkage

View Code
<Picker bind:show title="选择城市"
  columns={cityColumns}
  confirmButtonText="确定"
  cancelButtonText="取消"
  onConfirm={(val) => console.log(val)}
  onCancel={() => (show = false)}
  onChange={(val) => console.log(val)} />

Props

PropertyDescriptionTypeDefault
showWhether to showbooleanfalse
columnsColumns dataPickerColumn[][]
titleTop titlestring''
confirmButtonTextConfirm button textstring'确认'
cancelButtonTextCancel textstring'取消'
loadingWhether to show loadingbooleanfalse
readonlyWhether readonlybooleanfalse
showToolbarWhether to show toolbarbooleantrue
defaultIndexDefault selected indexnumber | string0
itemHeightOption height (px)number | string44
visibleItemCountVisible option countnumber | string6
swipeDurationMomentum duration on quick swipe (ms)number | string1000
onConfirmConfirm callbackFunction-
onCancelCancel callbackFunction-
onChangeOption change callbackFunction-

PickerGroup PickerGroup

Combine multiple pickers with tab switching

View Code
<PickerGroup title="预约日期时间"
  tabs={['选择日期', '选择时间']}
  nextStepText="下一步"
  bind:activeTab>
  <DatePicker />
  <TimePicker />
</PickerGroup>

Props

PropertyDescriptionTypeDefault
titleTop titlestring''
tabsTab liststring[][]
activeTabCurrent active tab indexnumber0
nextStepTextNext step button textstring'下一步'

NumberKeyboard NumberKeyboard

Virtual number keyboard with custom keys

View Code
<NumberKeyboard bind:show
  theme="default"
  title="输入金额"
  extraKey="."
  closeButtonText="完成"
  randomKeyOrder={false}
  onInput={(key) => console.log(key)}
  onDelete={() => console.log('delete')}
  onclose={() => console.log('close')} />

Props

PropertyDescriptionTypeDefault
showWhether to show keyboardbooleanfalse
themeTheme style'default' | 'custom''default'
titleKeyboard titlestring''
extraKeyExtra bottom keystring | string[]''
closeButtonTextDone button textstring'完成'
closeButtonLoadingWhether done button is loadingbooleanfalse
maxlengthMax input lengthnumber | stringInfinity
randomKeyOrderWhether to randomize key orderbooleanfalse
transitionWhether to enable transitionbooleantrue
blurOnCloseWhether to blur on closebooleantrue
hideOnClickOutsideWhether to close on outside clickbooleantrue
safeAreaInsetBottomWhether to adapt bottom safe areabooleantrue
onInputKey press callback(key: string) => void-
onDeleteDelete key callback() => void-
oncloseClose callback() => void-

PasswordInput PasswordInput

Password input used with NumberKeyboard

View Code
<PasswordInput value={password}
  length={6} mask
  focused={showKeyboard}
  info="密码为 6 位数字"
  errorInfo={errorMsg}
  gutter={10} />

Props

PropertyDescriptionTypeDefault
valuePassword valuestring''
lengthPassword lengthnumber | string6
maskWhether to mask passwordbooleantrue
focusedWhether focused (highlight current cell)booleanfalse
infoHint text below inputstring''
errorInfoError hint below inputstring''
gutterCell gap (px)number | string0

Uploader Uploader

File upload with camera and preview support

View Code
<Uploader bind:fileList
  maxCount={5} accept="image/*"
  maxSize={5 * 1024 * 1024}
  multiple preview
  deletable imageFit="cover"
  afterRead={(file) => uploadFile(file)}
  onOversize={(file) => toast('文件过大')}
  onDelete={(file) => console.log(file)} />

Props

PropertyDescriptionTypeDefault
fileListUploaded file listFileItem[][]
acceptAccepted file typesstring'image/*'
maxCountMax upload countnumber | stringInfinity
maxSizeFile size limit (bytes)number | stringInfinity
multipleWhether multiple selectionbooleanfalse
disabledWhether to disable uploadbooleanfalse
readonlyWhether readonlybooleanfalse
previewWhether to show preview after uploadbooleantrue
previewSizePreview and upload area sizenumber | string'80px'
previewImageWhether to preview full-screen on clickbooleantrue
previewFullImageWhether to show full-screen previewbooleantrue
deletableWhether to show delete buttonbooleantrue
imageFitPreview image fit modestring'cover'
uploadIconUpload area icon namestring'photograph'
uploadTextUpload area text hintstring''
afterReadAfter file read callbackFunction-
beforeReadBefore file read callbackFunction-
beforeDeleteBefore delete callbackFunction-
onOversizeOversize callbackFunction-
onDeleteDelete file callbackFunction-

Form Form

Form validation container wrapping Field components

View Code
<Form rules={formRules} labelWidth="6.2em"
  scrollToError validateFirst
  onSubmit={(values) => submit(values)}
  onFailed={(errors) => console.log(errors)}>
  <Field name="user" label="用户名" bind:value={user} />
  <Field name="pwd" label="密码" type="password" bind:value={pwd} />
</Form>

Props

PropertyDescriptionTypeDefault
rulesForm validation rulesobject{}
labelWidthForm label widthstring | number'6.2em'
labelAlignLabel alignment'left' | 'center' | 'right' | 'top''left'
inputAlignInput alignment'left' | 'center' | 'right''left'
errorMessageAlignError message alignment'left' | 'center' | 'right''left'
colonWhether to add colon after labelbooleanfalse
disabledWhether to disable all inputs in formbooleanfalse
readonlyWhether readonlybooleanfalse
validateFirstWhether to stop on first validation failurebooleanfalse
scrollToErrorWhether to scroll to error on failurebooleanfalse
showErrorWhether to highlight error inputsbooleanfalse
showErrorMessageWhether to show error message on failurebooleantrue
submitOnEnterWhether to submit on enterbooleantrue
onSubmitForm submit callbackFunction-
onFailedValidation failed callbackFunction-

Circle Circle

Circular progress bar with gradient and custom content

View Code
<Circle currentRate={70} rate={100}
  size="120px" color="#1989fa"
  layerColor="#ebedf0" strokeWidth={4}
  clockwise fill="none"
  speed={50} text="70%" />

Props

PropertyDescriptionTypeDefault
currentRateCurrent progressnumber0
rateTarget progressnumber100
sizeCircle diameterstring | number'100px'
colorProgress bar colorstring | object'#1989fa'
layerColorTrack colorstring'#fff'
fillFill colorstring'none'
speedAnimation speed (rate/s)number | string0
textText contentstring''
strokeWidthProgress bar widthnumber | string40
strokeLinecapLine cap style'round' | 'butt' | 'square''round'
clockwiseWhether clockwisebooleantrue
startPositionProgress start position'top' | 'bottom' | 'left' | 'right''top'

CountDown CountDown

Millisecond-level countdown timer

View Code
<CountDown time={30 * 60 * 60 * 1000}
  format="HH:mm:ss"
  autoStart millisecond={false}
  onFinish={() => console.log('结束')}
  onChange={(current) => console.log(current)} />

Props

PropertyDescriptionTypeDefault
timeTotal duration (ms)number0
formatTime formatstring'HH:mm:ss'
autoStartWhether to auto startbooleantrue
millisecondWhether to enable ms renderingbooleanfalse
onFinishCountdown finish callback() => void-
onChangeCountdown change callback(current: CurrentTime) => void-

Highlight Highlight

Highlight search keywords in text

View Code
<Highlight
  source="慕课网是好的学习平台"
  keywords={['学习', '平台']}
  highlightClass="custom-highlight"
  caseSensitive={false}
  unhighlightClass="normal-text" />

Props

PropertyDescriptionTypeDefault
sourceSource text contentstring''
keywordsHighlight keywordsstring | string[]''
highlightClassHighlight class namestring''
highlightTagHighlight HTML tagstring'span'
unhighlightClassUnhighlight class namestring''
unhighlightTagUnhighlight HTML tagstring'span'
caseSensitiveWhether case sensitivebooleanfalse

ImagePreview ImagePreview

Full-screen image preview with zoom support

View Code
<ImagePreview bind:show
  images={['a.jpg', 'b.jpg', 'c.jpg']}
  startPosition={0} closeable
  showIndex closeOnClickOverlay
  closeOnClickImage={false}
  maxZoom={3} minZoom={1/3}
  swipeDuration={300}
  onClose={() => {}} onChange={(index) => {}} />

Props

PropertyDescriptionTypeDefault
showWhether to show previewbooleanfalse
imagesImage URLs to previewstring[][]
startPositionInitial preview positionnumber | string0
closeableWhether to show close buttonbooleanfalse
showIndexWhether to show page indexbooleantrue
showIndicatorsWhether to show indicatorsbooleanfalse
closeOnClickOverlayWhether to close on overlay clickbooleantrue
closeOnClickImageWhether to close on image clickbooleantrue
closeIconClose icon namestring'clear'
closeIconPositionClose icon position'top-left' | 'top-right' | 'bottom-left' | 'bottom-right''top-right'
loopWhether to enable loopbooleantrue
maxZoomMax zoom rationumber3
minZoomMin zoom rationumber1/3
swipeDurationAnimation duration (ms)number | string300
onCloseClose callbackFunction-
onChangeImage change callback(index: number) => void-

Skeleton Skeleton

Loading placeholder skeleton screen

View Code
<!-- 基础用法 -->
<Skeleton title row={3} avatar round
  avatarSize="48px" avatarShape="round"
  rowWidth={['60%', '100%', '80%']}
  loading={isLoading}>
  <p>实际内容在这里显示</p>
</Skeleton>

<!-- 组合用法 -->
<SkeletonTitle />
<SkeletonAvatar />
<SkeletonParagraph row={4} rowWidth="100%" round />
<SkeletonImage />

Props

PropertyDescriptionTypeDefault
loadingWhether to show skeletonbooleantrue
rowParagraph row countnumber | string0
rowWidthParagraph row widthstring | string[]'100%'
titleWhether to show title placeholderbooleanfalse
titleWidthTitle placeholder widthstring | number'40%'
avatarWhether to show avatar placeholderbooleanfalse
avatarSizeAvatar placeholder sizestring | number'32px'
avatarShapeAvatar placeholder shape'round' | 'square''round'
roundWhether to round placeholdersbooleanfalse
animateWhether to enable animationbooleantrue

Steps Steps

Guide multi-step process

View Code
<Steps active={1} direction="horizontal"
  activeColor="#1989fa" inactiveColor="#969799"
  activeIcon="success" inactiveIcon="">
  <Step title="买家下单" description="描述信息" />
  <Step title="商家接单" />
  <Step title="买家提货" />
</Steps>

Props

PropertyDescriptionTypeDefault
activeCurrent step indexnumber | string0
directionSteps direction'horizontal' | 'vertical''horizontal'
activeColorActive state colorstring'#1989fa'
inactiveColorInactive state colorstring'#969799'
activeIconActive iconstring'checked'
inactiveIconInactive iconstring''
finishIconFinished step iconstring''
iconPrefixIcon class prefixstring'smu-icon'

Swipe Swipe

Carousel with gesture swipe support

View Code
<Swipe autoplay={3000} duration={500}
  loop showIndicators
  initialSwipe={0}
  touchable vertical={false}
  width="100%" height="200px"
  indicatorColor="#1989fa"
  onChange={(index) => console.log(index)}>
  <SwipeItem>1</SwipeItem>
  <SwipeItem>2</SwipeItem>
  <SwipeItem>3</SwipeItem>
</Swipe>

Props

PropertyDescriptionTypeDefault
autoplayAutoplay interval (ms), 0 to disablenumber | string0
durationAnimation duration (ms)number | string500
loopWhether to enable loopbooleantrue
showIndicatorsWhether to show indicatorsbooleantrue
initialSwipeInitial position indexnumber | string0
touchableWhether touchable to swipebooleantrue
verticalWhether vertical scrollbooleanfalse
widthSlide widthnumber | string'auto'
heightSlide heightnumber | string'auto'
indicatorColorIndicator colorstring'#1989fa'
stopPropagationWhether to prevent swipe propagationbooleantrue
onChangeSwipe page change callback(index: number) => void-

TextEllipsis TextEllipsis

Multi-line text ellipsis with expand/collapse

View Code
<TextEllipsis content={longText}
  rows={3}
  expandText="展开"
  collapseText="收起"
  dots="..."
  onClickAction={(expanded) => console.log(expanded)} />

Props

PropertyDescriptionTypeDefault
contentText to displaystring''
rowsDisplay rowsnumber | string1
expandTextExpand action textstring''
collapseTextCollapse action textstring''
dotsEllipsis textstring'...'
onClickActionExpand/collapse callback(expanded: boolean) => void-

Watermark Watermark

Add global watermark to page

View Code
<Watermark content="机密文档"
  image="" rotate={-22}
  width={100} height={100}
  gapX={100} gapY={100}
  opacity={0.15}
  fullPage zIndex={100}>
  <div>页面内容</div>
</Watermark>

Props

PropertyDescriptionTypeDefault
contentWatermark text contentstring''
imageWatermark image URL (higher priority than text)string''
widthWatermark widthnumber100
heightWatermark heightnumber100
rotateWatermark rotation anglenumber | string-22
gapXHorizontal gap between watermarksnumber100
gapYVertical gap between watermarksnumber100
opacityWatermark opacitynumber | string1
fullPageWhether to cover full pagebooleantrue
zIndexWatermark z-indexnumber | string100
textColorText colorstring'#dcdee0'
fontSizeText sizenumber | string14
fontWeightFont weightstring'normal'
fontFamilyFont familystring-

Barrage Barrage

Scrollable barrage component

View Code
<Barrage bind:modelValue={barrages}
  autoPlay rows={4}
  duration={4000} delay={300}
  top={10} bottom={10}>
  <video src="video.mp4" />
</Barrage>

Props

PropertyDescriptionTypeDefault
modelValueBarrage dataBarrageItem[][]
autoPlayWhether to auto play barragebooleantrue
rowsBarrage rowsnumber | string4
durationBarrage scroll duration (ms)number4000
delayBarrage animation delay (ms)number300
topBarrage area top distance (px)number | string10
bottomBarrage area bottom distance (px)number | string10

RollingText RollingText

Number rolling animation effect

View Code
<RollingText startNum={0}
  targetNum={9999}
  duration={2} autoStart
  direction="down"
  height={40}
  stopOrder={[]}
  textList={[]} />

Props

PropertyDescriptionTypeDefault
startNumStart valuenumber0
targetNumTarget valuenumber0
durationAnimation duration (s)number2
autoStartWhether to auto start animationbooleantrue
directionRolling direction'up' | 'down''down'
heightNumber height (px)number40
stopOrderStop order for each digitnumber[][]
textListCustom text arraystring[][]

List List

Auto load more on scroll bottom

View Code
<List loading={isLoading} finished={isFinished}
  offset={300} direction="down"
  immediateCheck={true}
  loadingText="加载中..."
  finishedText="没有更多了"
  errorText="加载失败"
  onLoad={loadMore}>
  {#each list as item}
    <Cell title={item.title} />
  {/each}
</List>

Props

PropertyDescriptionTypeDefault
loadingWhether loadingbooleanfalse
finishedWhether all data loadedbooleanfalse
errorWhether load failedbooleanfalse
offsetDistance threshold to trigger load (px)number | string300
directionScroll trigger direction'up' | 'down''down'
immediateCheckWhether to check immediatelybooleantrue
loadingTextLoading textstring'加载中...'
finishedTextFinished textstring''
errorTextError textstring''
onLoadTrigger when scroll distance to bottom < offset() => void-

Notify Notify

Top notification bar

View Code
<Notify bind:show type="success"
  message="操作成功"
  duration={2000}
  color="#fff"
  background="#1989fa"
  lockScroll={false}
  onclick={() => {}} />

Props

PropertyDescriptionTypeDefault
showWhether to show notificationbooleanfalse
typeType'primary' | 'success' | 'warning' | 'danger''danger'
messageDisplay messagestring''
durationDuration (ms), 0 for persistentnumber | string3000
colorFont colorstring''
backgroundBackground colorstring''
classNameCustom class namestring''
lockScrollWhether to lock background scrollbooleanfalse
onclickClick callback() => void-
oncloseClose callback() => void-
onOpenedFully displayed callback() => void-

Popover Popover

Popover menu/tooltip

View Code
<Popover bind:show placement="bottom-start"
  theme="light" trigger="click"
  actions={[
    { text: '选项一', icon: 'add-o' },
    { text: '选项二', icon: 'music-o' },
    { text: '选项三', disabled: true },
  ]}
  closeOnClickAction
  closeOnClickOutside
  onSelect={(action) => console.log(action)} />

Props

PropertyDescriptionTypeDefault
showWhether to show popoverbooleanfalse
actionsOptions listPopoverAction[][]
actionsDirectionOptions direction'vertical' | 'horizontal''vertical'
placementPopup positionstring'bottom'
themeTheme style'light' | 'dark''light'
triggerTrigger method'click' | 'manual''click'
offsetPosition offset[number, number][0, 8]
overlayWhether to show overlaybooleanfalse
showArrowWhether to show arrowbooleantrue
closeOnClickActionWhether to close on selectbooleantrue
closeOnClickOutsideWhether to close on outside clickbooleantrue
closeOnClickOverlayWhether to close on overlay clickbooleantrue
durationAnimation duration (s)number | string0.3
onSelectOption select callback(action: PopoverAction) => void-
onOpenOpen callback() => void-
onCloseClose callback() => void-

PullRefresh PullRefresh

Pull-to-refresh container

View Code
<PullRefresh bind:loading
  successText="刷新成功"
  pullingText="下拉即可刷新..."
  loosingText="释放即可刷新..."
  loadingText="加载中..."
  successDuration={500}
  headHeight={50}
  onRefresh={onRefresh}>
  <p>内容区域</p>
</PullRefresh>

Props

PropertyDescriptionTypeDefault
loadingWhether loadingbooleanfalse
pullingTextPulling textstring'下拉即可刷新...'
loosingTextLoosing textstring'释放即可刷新...'
loadingTextLoading textstring'加载中...'
successTextSuccess textstring''
successDurationSuccess duration (ms)number | string500
animationDurationAnimation duration (ms)number | string300
headHeightHead height (px)number | string50
pullDistancePull distance thresholdnumber | string与 headHeight 一致
disabledWhether to disable pull refreshbooleanfalse
onRefreshRefresh callback() => void-

ShareSheet ShareSheet

Bottom share options panel

View Code
<ShareSheet bind:show
  title="立即分享给好友"
  description="描述信息"
  cancelText="取消"
  options={[
    [
      { name: '微信', icon: 'wechat' },
      { name: '朋友圈', icon: 'wechat-moments' },
    ],
    [
      { name: '复制链接', icon: 'link' },
      { name: '二维码', icon: 'qrcode' },
    ],
  ]}
  onSelect={(option, index) => console.log(option)}
  onCancel={() => (show = false)} />

Props

PropertyDescriptionTypeDefault
showWhether to show share sheetbooleanfalse
optionsShare optionsShareOption[] | ShareOption[][][]
titleTop titlestring''
descriptionDescription below titlestring''
cancelTextCancel textstring'取消'
closeableWhether to show close iconbooleantrue
closeOnClickOverlayWhether to close on overlay clickbooleantrue
closeOnPopstateWhether to close on page backbooleantrue
durationAnimation duration (s)number | string0.3
safeAreaInsetBottomWhether to adapt bottom safe areabooleantrue
onSelectShare option select callback(option, index) => void-
onCancelCancel button click callback() => void-
oncloseClose callback() => void-

SwipeCell SwipeCell

Left/right swipe actions

View Code
<SwipeCell disabled={false}
  stopPropagation
  beforeClose={onBeforeClose}>
  {#snippet left()}<Button square type="primary" text="选择" />{/snippet}
  <Cell title="单元格" value="内容" />
  {#snippet right()}<Button square type="danger" text="删除" />{/snippet}
</SwipeCell>

Props

PropertyDescriptionTypeDefault
disabledWhether to disable swipebooleanfalse
nameIdentifierstring | number''
stopPropagationWhether to prevent swipe propagationbooleanfalse
beforeCloseBefore close callbackFunction-
onOpenOpen callback(params: { name, position }) => void-
onCloseClose callback(params: { name, position }) => void-
onclickClick callback(position: string) => void-

FloatingPanel FloatingPanel

Draggable bottom floating panel

View Code
<FloatingPanel
  anchors={[100, 300, window.innerHeight * 0.6]}
  height={0} minHeight={100}
  contentDraggable lockScroll={false}
  safeAreaInsetBottom
  onHeightChange={({ height }) => console.log(height)}>
  <p>面板内容</p>
</FloatingPanel>

Props

PropertyDescriptionTypeDefault
anchorsSet custom anchors (height array)number[][100, 窗口60%]
heightCurrent panel heightnumber0
minHeightMin heightnumber100
maxHeightMax heightnumber0
contentDraggableWhether to allow content dragbooleantrue
lockScrollWhether to lock background scrollbooleanfalse
safeAreaInsetBottomWhether to adapt bottom safe areabooleantrue
durationAnimation duration (s)number | string0.3
onHeightChangeHeight change callback(params: { height }) => void-

FloatingBubble FloatingBubble

Draggable floating bubble button

View Code
<FloatingBubble icon="chat"
  offset={{ x: -60, y: -60 }}
  gap={24} magnetic="x"
  axis="xy"
  onclick={() => console.log('click')} />

Props

PropertyDescriptionTypeDefault
iconIcon name or image URLstring''
offsetControl bubble initial position{ x: number, y: number }{ x: -30, y: -30 }
gapMin gap from window edges (px)number24
magneticAuto magnetic direction'x' | 'y' | ''''
axisDrag direction'x' | 'y' | 'xy' | 'lock''y'
onclickBubble click callback() => void-
onOffsetChangePosition change callback(offset: { x, y }) => void-

Grid Grid

Grid layout for content entries

View Code
<Grid columnNum={4} border center
  square={false} gutter={0}
  iconSize="28px" clickable
  direction="vertical" reverse={false}>
  <GridItem icon="photo" text="文字" dot />
  <GridItem icon="photo" text="文字" badge="99+" />
  <GridItem icon="photo" text="文字" url="/detail" />
</Grid>

Props

PropertyDescriptionTypeDefault
columnNumColumn countnumber | string4
iconSizeIcon sizestring | number'28px'
gutterCell gap (px)number | string0
borderWhether to show borderbooleantrue
centerWhether to center cell contentbooleantrue
squareWhether to fix cells as squarebooleanfalse
clickableWhether to enable cell click feedbackbooleanfalse
directionCell content direction'vertical' | 'horizontal''vertical'
reverseWhether to reverse icon and textbooleanfalse
textText (GridItem)string''
iconIcon name (GridItem)string''
iconColorIcon color (GridItem)string''
dotWhether to show dot (GridItem)booleanfalse
badgeBadge content (GridItem)string | number''
urlClick link (GridItem)string''

IndexBar IndexBar

Alphabetical index list navigation

View Code
<IndexBar indexList={['A','B','C','D']}
  sticky stickyOffsetTop={0}
  highlightColor="#1989fa"
  onSelect={(index) => console.log(index)}
  onChange={(index) => console.log(index)}>
  <IndexAnchor index="A" />
  <Cell title="Aaron" />
  <Cell title="Alex" />
  <IndexAnchor index="B" />
  <Cell title="Bob" />
</IndexBar>

Props

PropertyDescriptionTypeDefault
indexListIndex character liststring[] | number[]A-Z
stickyWhether to enable sticky indexbooleantrue
stickyOffsetTopSticky anchor top offset (px)number0
highlightColorIndex highlight colorstring'#1989fa'
zIndexZ-index when stickynumber | string1
teleportSidebar mount containerstring | Element-
onSelectIndex select callback(index: string | number) => void-
onChangeActive index change callback(index: string | number) => void-
indexIndex character (IndexAnchor)string | number''

Pagination Pagination

Pagination navigator

View Code
<Pagination bind:currentPage
  totalItems={100} itemsPerPage={10}
  showPageSize={5} mode="simple"
  forceEllipses
  prevText="上一页" nextText="下一页"
  onChange={(page) => loadPage(page)} />

Props

PropertyDescriptionTypeDefault
currentPageCurrent pagenumber1
totalItemsTotal itemsnumber | string0
itemsPerPageItems per pagenumber | string10
showPageSizeVisible page countnumber | string5
modeDisplay mode'simple' | 'multi''multi'
forceEllipsesWhether to force ellipsisbooleanfalse
prevTextPrevious button textstring'上一页'
nextTextNext button textstring'下一页'
onChangePage change callback(page: number) => void-

Sidebar Sidebar

Vertical navigation bar

View Code
<Sidebar bind:activeKey
  onChange={(key) => console.log(key)}>
  <SidebarItem title="标签一" />
  <SidebarItem title="标签二" dot />
  <SidebarItem title="标签三" badge={5} />
  <SidebarItem title="标签四" disabled />
</Sidebar>

Props

PropertyDescriptionTypeDefault
activeKeyCurrent active indexnumber | string0
onChangeNavigation change callback(key: number) => void-
titleLabel (SidebarItem)string''
dotWhether to show dot (SidebarItem)booleanfalse
badgeBadge content (SidebarItem)string | number''
disabledWhether disabled (SidebarItem)booleanfalse
onclickClick callback (SidebarItem)Function-

Sticky Sticky

Sticky positioning effect similar to CSS position: sticky

View Code
<Sticky offsetTop={50} zIndex={99}
  position="top" container={container}
  onChange={(isFixed) => console.log(isFixed)}
  onScroll={({ scrollTop, isFixed }) => {}}>
  <Button type="primary">吸顶按钮</Button>
</Sticky>

Props

PropertyDescriptionTypeDefault
offsetTopTop offset when sticky (px)number | string0
offsetBottomBottom offset when sticky (px)number | string0
zIndexZ-index when stickynumber | string99
positionSticky position'top' | 'bottom''top'
containerContainer HTML elementHTMLElement-
onChangeSticky state change callback(isFixed: boolean) => void-
onScrollScroll callback(params: { scrollTop, isFixed }) => void-

BackTop BackTop

Back to top button

View Code
<BackTop target=".scroll-container"
  visibilityHeight={200}
  right={30} bottom={60}
  zIndex={100}
  onclick={() => console.log('top')} />

Props

PropertyDescriptionTypeDefault
targetTarget element selector for scrollstring | HTMLElement-
visibilityHeightShow when scroll height reaches this value (px)number | string200
rightRight offset from page (px)number | string30
bottomBottom offset from page (px)number | string40
zIndexZ-indexnumber | string100
teleportMount containerstring | Element'body'
onclickClick callback() => void-

TreeSelect TreeSelect

Left category + right content list

View Code
<TreeSelect items={treeItems}
  bind:activeId bind:mainActiveIndex
  height="300px" max={Infinity}
  selectedIcon="success"
  onClickNav={(index) => console.log(index)}
  onClickItem={(item) => console.log(item)} />

Props

PropertyDescriptionTypeDefault
itemsCategory display dataTreeSelectItem[][]
activeIdRight side active item idnumber | string | (number | string)[]0
mainActiveIndexLeft side active indexnumber | string0
heightHeightnumber | string300
maxMax selectable on right sidenumber | stringInfinity
selectedIconSelected item iconstring'success'
onClickNavLeft nav click callback(index: number) => void-
onClickItemRight item click callback(item: TreeSelectChild) => void-

DropdownMenu DropdownMenu

Dropdown menu list

View Code
<DropdownMenu activeColor="#1989fa"
  direction="down" overlay
  closeOnClickOutside
  closeOnClickOverlay
  duration={0.2} zIndex={10}>
  <DropdownItem title="排序" options={sortOpts}
    bind:value={sort} onchange={(v) => {}} />
  <DropdownItem title="筛选" options={filterOpts}
    bind:value={filter} />
</DropdownMenu>

Props

PropertyDescriptionTypeDefault
activeColorActive color for title and optionsstring'#1989fa'
directionMenu expand direction'up' | 'down''down'
overlayWhether to show overlaybooleantrue
closeOnClickOutsideWhether to close on outside clickbooleantrue
closeOnClickOverlayWhether to close on overlay clickbooleantrue
durationAnimation duration (s)number | string0.2
zIndexMenu bar z-indexnumber | string10
swipeThresholdScroll thresholdnumber | string5
valueCurrent value (DropdownItem)string | number-
titleItem title (DropdownItem)string''
disabledWhether disabled (DropdownItem)booleanfalse
optionsOptions data (DropdownItem)Option[][]
onchangeOption change callback (DropdownItem)(value) => void-
onOpenOpen callback (DropdownItem)() => void-
onCloseClose callback (DropdownItem)() => void-

ActionBar ActionBar

Bottom action bar for product detail page

View Code
<ActionBar>
  <ActionBarIcon icon="chat-o" text="客服"
    dot color="" badge="" url="" />
  <ActionBarIcon icon="cart-o" text="购物车"
    badge="5" url="" />
  <ActionBarIcon icon="shop-o" text="店铺" />
  <ActionBarButton type="warning" text="加入购物车"
    color="" loading={false} disabled={false} />
  <ActionBarButton type="danger" text="立即购买" />
</ActionBar>

Props

PropertyDescriptionTypeDefault
iconIcon name (ActionBarIcon)string''
textButton textstring''
colorIcon color (ActionBarIcon)string''
dotWhether to show dot (ActionBarIcon)booleanfalse
badgeBadge content (ActionBarIcon)string | number''
urlClick link (ActionBarIcon)string''
onclickClick callback (ActionBarIcon)Function-
typeButton type (ActionBarButton)string'danger'
colorButton color (ActionBarButton)string''
iconButton icon (ActionBarButton)string''
loadingWhether loading (ActionBarButton)booleanfalse
disabledWhether disabled (ActionBarButton)booleanfalse

Row / Col 栅格

24-column grid layout system

View Code
<Row gutter={20} justify="center" align="top"
  wrap tag="div">
  <Col span={8} offset={0}>span: 8</Col>
  <Col span={8}>span: 8</Col>
  <Col span={8}>span: 8</Col>
</Row>

Props

PropertyDescriptionTypeDefault
gutterColumn gap (px)number | string0
justifyMain axis alignment'start' | 'end' | 'center' | 'space-around' | 'space-between''start'
alignCross axis alignment'top' | 'center' | 'bottom''top'
wrapWhether to wrapbooleantrue
tagCustom root element tagstring'div'
spanColumn width (Col, 1-24)number | string-
offsetColumn offset (Col)number | string0
tagCustom tag (Col)string'div'

Space Space

Set gap between elements

View Code
<Space direction="horizontal" fill={false}
  wrap="nowrap" align="start">
  <Button type="primary">按钮 1</Button>
  <Button type="primary">按钮 2</Button>
  <Button type="primary">按钮 3</Button>
</Space>

Props

PropertyDescriptionTypeDefault
directionGap direction'horizontal' | 'vertical''horizontal'
fillWhether to fill entire rowbooleanfalse
wrapWhether to wrap'nowrap' | 'wrap''nowrap'
alignCross axis alignment'start' | 'center' | 'end' | 'baseline''start'

AddressEdit AddressEdit

Shipping address form editing

View Code
<AddressEdit addressInfo={addressInfo}
  areaList={areaData}
  showPostal showSetDefault
  showSearchResult={false}
  isEdit={false}
  showDelete={false}
  showArea saveButtonText="保存"
  deleteButtonText="删除"
  areaColumnsPlaceholder={['请选择', '请选择', '请选择']}
  telValidator={(tel) => /^1[3-9]d{9}$/.test(tel)}
  onSave={(info) => saveAddress(info)}
  onDelete={(info) => deleteAddress(info)}
  onChange={(info) => console.log(info)}
  onChangeDetail={(val) => {}} />

Props

PropertyDescriptionTypeDefault
addressInfoRecipient info objectAddressInfo{}
areaListArea dataobject{}
showPostalWhether to show postal codebooleanfalse
showSetDefaultWhether to show default address barbooleanfalse
showSearchResultWhether to show search resultbooleanfalse
showAreaWhether to show areabooleantrue
showDeleteWhether to show delete buttonbooleanfalse
isEditWhether edit modebooleanfalse
saveButtonTextSave button textstring'保存'
deleteButtonTextDelete button textstring'删除'
areaColumnsPlaceholderArea column placeholderstring[][]
telValidatorPhone validator function(tel: string) => boolean-
onSaveSave callback(info: AddressInfo) => void-
onDeleteDelete callback(info: AddressInfo) => void-
onChangeForm change callback(info: AddressInfo) => void-
onChangeDetailDetail change callback(val: string) => void-

AddressList AddressList

Display/switch address list

View Code
<AddressList list={addresses}
  chosenId={selectedId}
  addButtonText="新增地址"
  defaultTagText="默认"
  disabledText="以下地址超出配送范围"
  disabledList={disabledAddresses}
  switchable
  onAdd={() => addNew()}
  onSelect={(item, index) => select(item)}
  onEdit={(item, index) => edit(item)}
  onClickItem={(item, index) => {}} />

Props

PropertyDescriptionTypeDefault
listAddressListAddressItem[][]
disabledListNon-deliverable address listAddressItem[][]
chosenIdCurrent selected address idstring | number''
addButtonTextBottom add button textstring'新增地址'
defaultTagTextDefault address tag textstring''
disabledTextNon-deliverable area hintstring''
switchableWhether to allow address switchingbooleantrue
onAddAdd button click callback() => void-
onSelectSwitch selected address callback(item, index) => void-
onEditEdit button click callback(item, index) => void-
onClickItemAddress item click callback(item, index) => void-

Area Area

Province/city/district cascading select

View Code
<Area bind:show title="选择地区"
  areaList={areaData}
  value="110101"
  columnsNum={3}
  columnsPlaceholder={['请选择', '请选择', '请选择']}
  onConfirm={(val) => console.log(val)}
  onCancel={() => (show = false)}
  onChange={(val) => console.log(val)} />

Props

PropertyDescriptionTypeDefault
showWhether to showbooleanfalse
valueCurrent selected area codestring''
titleToolbar titlestring''
areaListArea dataobject{}
columnsNumColumns count (1-3)number | string3
columnsPlaceholderColumn placeholder textstring[][]
loadingWhether to show loadingbooleanfalse
readonlyWhether readonlybooleanfalse
confirmButtonTextConfirm button textstring'确认'
cancelButtonTextCancel textstring'取消'
onConfirmConfirm callbackFunction-
onCancelCancel callbackFunction-
onChangeOption change callbackFunction-

Card Card

Product card for displaying image, price, etc.

View Code
<Card title="商品名称"
  price="2.00" originPrice="10.00"
  desc="描述信息" num={2}
  thumb="https://img.example.com/thumb.jpg"
  tag="标签" currency="¥"
  centered lazyLoad
  thumbLink="" />

Props

PropertyDescriptionTypeDefault
titleProduct titlestring''
priceProduct pricestring | number''
originPriceOriginal price (strikethrough)string | number''
descProduct descriptionstring''
numProduct quantitystring | number''
thumbLeft image URLstring''
tagTag contentstring''
currencyCurrency symbolstring'¥'
centeredWhether to center content verticallybooleanfalse
lazyLoadWhether to lazy load imagebooleanfalse
thumbLinkImage click linkstring''

ContactCard ContactCard

Display/add contact info

View Code
<ContactCard type="edit"
  name="张三" tel="13000000000"
  addText="添加联系人"
  editable
  onclick={() => editContact()} />

Props

PropertyDescriptionTypeDefault
typeCard type'add' | 'edit''add'
nameContact namestring''
telContact phonestring''
addTextAdd textstring'添加联系人'
editableWhether editablebooleantrue
onclickClick callback() => void-

ContactEdit ContactEdit

Contact form editing

View Code
<ContactEdit
  contactInfo={{ name: '张三', tel: '13000000000' }}
  isEditing isSaving={false}
  showSetDefault
  setDefaultLabel="设为默认联系人"
  telValidator={(tel) => /^1[3-9]d{9}$/.test(tel)}
  onSave={(info) => saveContact(info)}
  onDelete={(info) => deleteContact(info)} />

Props

PropertyDescriptionTypeDefault
contactInfoContact info{ name?: string, tel?: string, isDefault?: boolean }{}
isEditingWhether edit modebooleanfalse
isSavingWhether to show saving statebooleanfalse
showSetDefaultWhether to show default contact barbooleantrue
setDefaultLabelDefault contact textstring'设为默认联系人'
telValidatorPhone number validator(tel: string) => boolean-
onSaveSave callback(info) => void-
onDeleteDelete contact callback(info) => void-

ContactList Contact list

Contact list selection

View Code
<ContactList list={contacts}
  addText="新建联系人"
  defaultTagText="默认"
  onAdd={() => addNewContact()}
  onEdit={(item, index) => editContact(item)}
  onSelect={(item, index) => selectContact(item)} />

Props

PropertyDescriptionTypeDefault
listContact listContactItem[][]
addTextAdd button textstring'新建联系人'
defaultTagTextDefault contact tag textstring'默认'
onAddAdd button click callback() => void-
onEditEdit click callback(item, index) => void-
onSelectSwitch selected contact callback(item, index) => void-

Coupon / CouponList 优惠券

Coupon display and selection

View Code
<CouponList
  coupons={availableCoupons}
  disabledCoupons={usedCoupons}
  bind:chosenCoupon
  bind:code
  enabledTitle="可用优惠券"
  disabledTitle="不可用优惠券"
  exchangeButtonText="兑换"
  showExchangeBar showCloseButton
  showCount currency="¥"
  closeButtonText="不使用优惠"
  inputPlaceholder="请输入优惠码"
  onchange={(index) => selectCoupon(index)}
  onexchange={(code) => exchangeCoupon(code)} />

Props

PropertyDescriptionTypeDefault
couponsAvailable couponsCouponInfo[][]
disabledCouponsDisabled couponsCouponInfo[][]
chosenCouponCurrent selected coupon indexnumber-1
codeExchange codestring''
enabledTitleAvailable coupons titlestring'可用优惠券'
disabledTitleDisabled coupons titlestring'不可用优惠券'
exchangeButtonTextExchange button textstring'兑换'
exchangeButtonLoadingWhether exchange button loadingbooleanfalse
exchangeButtonDisabledWhether exchange button disabledbooleanfalse
showExchangeBarWhether to show exchange barbooleantrue
showCloseButtonWhether to show close buttonbooleantrue
showCountWhether to show countsbooleantrue
closeButtonTextList bottom button textstring'不使用优惠'
inputPlaceholderInput placeholder textstring'请输入优惠码'
currencyCurrency symbolstring'¥'
emptyImageEmpty list placeholder imagestring''
onchangeCoupon change callback(index: number) => void-
onexchangeExchange callback(code: string) => void-

Signature Signature

Handwriting signature pad

View Code
<Signature type="png"
  penColor="#000" lineWidth={3}
  backgroundColor=""
  clearButtonText="清空"
  confirmButtonText="确认"
  onclear={() => console.log('cleared')}
  onconfirm={({ image, canvas }) => saveSignature(image)}
  onstart={() => console.log('start')}
  onsigning={() => {}}
  onend={() => console.log('end')} />

Props

PropertyDescriptionTypeDefault
typeExport image typestring'png'
penColorStroke colorstring'#000'
lineWidthLine widthnumber3
backgroundColorCanvas background colorstring''
clearButtonTextClear button textstring'清空'
confirmButtonTextConfirm button textstring'确认'
onclearClear callback() => void-
onconfirmConfirm button click callback(data: { image, canvas }) => void-
onstartSigning start callback() => void-
onsigningSigning callback() => void-
onendSigning end callback() => void-

SubmitBar SubmitBar

Bottom submit bar for cart/checkout page

View Code
<SubmitBar price={3050}
  buttonText="提交订单"
  disabled={!hasChecked}
  loading={submitting}
  currency="¥" decimalLength={2}
  suffixLabel=""
  textAlign="right"
  buttonType="danger"
  tipText="提示信息"
  tipIcon="info-o"
  safeAreaInsetBottom
  placeholder
  onSubmit={() => submitOrder()} />

Props

PropertyDescriptionTypeDefault
priceAmount (in cents)number0
buttonTextButton textstring''
buttonTypeButton typestring'danger'
buttonColorButton colorstring''
loadingWhether to show loading buttonbooleanfalse
disabledWhether to disable buttonbooleanfalse
tipTextTip textstring''
tipIconTip iconstring''
currencyCurrency symbolstring'¥'
decimalLengthPrice decimal placesnumber | string2
suffixLabelText after pricestring''
textAlignPrice text alignment'left' | 'right''right'
labelText before pricestring'合计:'
safeAreaInsetBottomWhether to adapt bottom safe areabooleantrue
placeholderWhether to generate placeholder abovebooleanfalse
onSubmitButton click callback() => void-

ConfigProvider ConfigProvider

Global theme config, CSS variable injection

View Code
<ConfigProvider theme="dark"
  themeVars={{
    primaryColor: '#07c160',
    successColor: '#67c23a',
    buttonPrimaryBackground: '#07c160',
  }}
  tag="div"
  iconPrefix="smu-icon">
  <App />
</ConfigProvider>

Props

PropertyDescriptionTypeDefault
themeTheme mode'light' | 'dark''light'
themeVarsCustom theme CSS variablesobject{}
themeVarsDarkDark mode CSS variablesobject{}
themeVarsLightLight mode CSS variablesobject{}
tagRoot HTML tag namestring'div'
zIndexSet z-index for all popup componentsnumber2000
iconPrefixIcon class prefix for all iconsstring'smu-icon'