• 开始
    • Introduction 介绍
    • Getting Started 快速开始
    • Customized Themes 定制主题
    • Design to Code 设计稿转代码
    • Dark Mode 暗色模式
    • Accessibility 无障碍
    • Content Guidelines 文案规范
    • Change Log 更新日志
    • FAQ 常见问题
    • Overview 组件总览
  • 基础
    • Divider 分割线
    • Grid 栅格
    • Resizable 伸缩框
    • Icon 图标
    • Layout 布局
    • Space 间距
    • Typography 版式
  • Plus 组件
    • Chat 对话
    • DragMove 拖拽移动
    • Codehighlight 代码高亮
    • Hotkeys 热键
    • Lottie 动画
    • Markdown 渲染
    • AudioPlayer 播放器
  • 输入类
    • AutoComplete 自动完成
    • Button 按钮
    • Cascader 级联选择
    • Checkbox 复选框
    • ColorPicker 颜色选择器
    • DatePicker 日期选择器
    • Form 表单
    • Input 输入框
    • InputNumber 数字输入框
    • PinCode 验证码输入
    • Radio 单选框
    • Rating 评分
    • Select 选择器
    • Slider 滑动选择器
    • Switch 开关
    • TagInput 标签输入框
    • TimePicker 时间选择器
    • Transfer 穿梭框
    • TreeSelect 树选择器
    • Upload 上传
  • 导航类
    • Anchor 锚点
    • BackTop 回到顶部
    • Breadcrumb 面包屑
    • Navigation 导航
    • Pagination 翻页器
    • Steps 步骤
    • Tabs 标签栏
    • Tree 树形控件
  • 展示类
    • Avatar 头像
    • Badge 徽章
    • Calendar 日历
    • Card 卡片
    • Carousel 轮播图
    • Collapse 折叠面板
    • Collapsible 折叠
    • Descriptions 描述列表
    • Dropdown 下拉框
    • Empty 空状态
    • Highlight 高亮文本
    • Image 图片
    • Cropper 图片裁剪
    • List 列表
    • Modal 模态对话框
    • OverflowList 折叠列表
    • Popover 气泡卡片
    • ScrollList 滚动列表
    • SideSheet 滑动侧边栏
    • Table 表格
    • Tag 标签
    • Timeline 时间轴
    • Tooltip 工具提示
    • UserGuide 用户引导
  • 反馈类
    • Banner 通知横幅
    • Notification 通知
    • Popconfirm 气泡确认框
    • Progress 进度条
    • Skeleton 骨架屏
    • Spin 加载器
    • Toast 提示
  • 其他
    • ConfigProvider 全局配置
    • LocaleProvider 多语言
On this page
  • 代码演示
    • 如何引入
    • 基本用法
    • 主题切换
    • 指示器
    • 箭头
    • 定制箭头
    • 播放参数
    • 动画效果与切换速度
    • 受控的轮播图
    • API 参考
  • Methods
  • 设计变量

代码演示 ​

如何引入 ​

jsx
import { Carousel } from '@kousum/semi-ui-vue';

基本用法 ​

基本用法

0px x 0px
demoApp.vue
demo.tsx
tsconfig.json
Import Map
xxxxxxxxxx
11
7
60
 
1
import { Carousel, Typography, Space } from '@kousum/semi-ui-vue';
2
​
3
export default () => {
4
    const { Title, Paragraph } = Typography;
5
​
6
    const style = {
7
        width: '100%',
8
        height: '400px',
9
    };
10
​
11
    const titleStyle = { 
12
        position: 'absolute', 
13
        top: '100px', 
14
        left: '100px',
15
        color: '#1C1F23'
16
    };
17
​
18
    const colorStyle = {
19
        color: '#1C1F23'
20
    };
21
​
22
    const renderLogo = () => {
23
        return (
24
            <img src='https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/semi_logo.svg' alt='semi_logo' style={{ width: '87px', height: '31px' }} />   
25
        );
26
    };
27
​
28
    const imgList = [
Show Error
Auto Save

主题切换 ​

默认定义了三种主题: primary、light、dark

0px x 0px
demoApp.vue
demo.tsx
tsconfig.json
Import Map
xxxxxxxxxx
11
7
75
 
1
import { Carousel, RadioGroup, Radio, Space, Typography } from '@kousum/semi-ui-vue';
2
import { defineComponent, ref } from 'vue';
3
const { Title, Paragraph } = Typography;
4
​
5
const Demo = defineComponent(()=>{
6
​
7
  const theme = ref('primary');
8
​
9
  const style = {
10
    width: '100%',
11
    height: '400px',
12
  };
13
​
14
  const titleStyle = {
15
    position: 'absolute',
16
    top: '100px',
17
    left: '100px'
18
  };
19
​
20
  const colorStyle = {
21
    color: '#1C1F23'
22
  };
23
​
24
  const renderLogo = () => {
25
    return (
26
      <img src='https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/semi_logo.svg'
27
           alt='semi_logo' style={{ width: '87px', height: '31px' }} />
28
    );
Show Error
Auto Save

指示器 ​

指示器可以调节类型、位置、尺寸
类型: dot、line、columnar
位置: left、center、right
尺寸: small、medium

0px x 0px
demoApp.vue
demo.tsx
tsconfig.json
Import Map
xxxxxxxxxx
11
7
96
 
1
import { Carousel, RadioGroup, Radio, Space, Typography } from '@kousum/semi-ui-vue';
2
import { defineComponent, ref } from 'vue';
3
​
4
const { Title, Paragraph } = Typography;
5
​
6
​
7
const Demo = defineComponent(()=>{
8
  const size = ref('small');
9
  const type = ref('dot');
10
  const position = ref('left');
11
​
12
  const style = {
13
    width: '100%',
14
    height: '400px',
15
  };
16
​
17
  const titleStyle = {
18
    position: 'absolute',
19
    top: '100px',
20
    left: '100px'
21
  };
22
​
23
  const colorStyle = {
24
    color: '#1C1F23'
25
  };
26
​
27
  const renderLogo = () => {
28
    return (
Show Error
Auto Save

箭头 ​

通过 showArrow 属性控制箭头是否可见
如果箭头可见,通过 arrowType 属性控制箭头展示的时机

0px x 0px
demoApp.vue
demo.tsx
tsconfig.json
Import Map
xxxxxxxxxx
11
7
86
 
1
import { Carousel, RadioGroup, Radio, Space, Typography } from '@kousum/semi-ui-vue';
2
import { defineComponent, ref } from 'vue';
3
​
4
const { Title, Paragraph } = Typography;
5
​
6
​
7
const Demo = defineComponent(() => {
8
​
9
  const arrowType = ref('always');
10
  const show = ref(true);
11
​
12
  const style = {
13
    width: '100%',
14
    height: '400px',
15
  };
16
​
17
  const titleStyle = {
18
    position: 'absolute',
19
    top: '100px',
20
    left: '100px'
21
  };
22
​
23
  const colorStyle = {
24
    color: '#1C1F23'
25
  };
26
​
27
  const renderLogo = () => {
28
    return (
Show Error
Auto Save

定制箭头 ​

通过 arrowProps 属性定制箭头样式和点击事件

0px x 0px
demoApp.vue
demo.tsx
tsconfig.json
Import Map
xxxxxxxxxx
11
7
76
 
1
import { Carousel, Typography, Space } from '@kousum/semi-ui-vue';
2
import { IconArrowLeft, IconArrowRight } from "@kousum/semi-icons-vue";
3
import { defineComponent } from 'vue';
4
​
5
​
6
​
7
const CarouselDemo = defineComponent(()=>{
8
​
9
  const imgList = [
10
    'https://lf3-static.bytednsdoc.com/obj/eden-cn/hjeh7pldnulm/SemiDocs/bg-1.png',
11
    'https://lf3-static.bytednsdoc.com/obj/eden-cn/hjeh7pldnulm/SemiDocs/bg-2.png',
12
    'https://lf3-static.bytednsdoc.com/obj/eden-cn/hjeh7pldnulm/SemiDocs/bg-3.png',
13
  ];
14
  const textList = [
15
    ['Semi 设计管理系统', '从 Semi Design,到 Any Design', '快速定制你的设计系统,并应用在设计稿和代码中'],
16
    ['Semi 物料市场', '面向业务场景的定制化组件,支持线上预览和调试', '内容由 Semi Design 用户共建'],
17
    ['Semi 设计/代码模板', '高效的 Design2Code 设计稿转代码', '海量 Figma 设计模板一键转为真实前端代码'],
18
  ];
19
  const arrowProps = {
20
    leftArrow: { children: <IconArrowLeft size='large' /> },
21
    rightArrow: { children: <IconArrowRight size='large' /> },
22
  };
23
  function renderLogo() {
24
    return (
25
      <img src='https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/semi_logo.svg'
26
           alt='semi_logo' style={{ width: '87px', height: '31px' }} />
27
    );
28
  };
Show Error
Auto Save

播放参数 ​

通过给 autoPlay 传入参数 interval 控制两张图片之间的时间间隔,传入 hoverToPause 控制鼠标放置在图片上时是否停止播放

0px x 0px
demoApp.vue
demo.tsx
tsconfig.json
Import Map
xxxxxxxxxx
11
7
61
 
1
import { Carousel, Typography, Space } from '@kousum/semi-ui-vue';
2
const { Title, Paragraph } = Typography;
3
​
4
export default () => {
5
​
6
    const style = {
7
        width: '100%',
8
        height: '400px',
9
    };
10
​
11
    const titleStyle = { 
12
        position: 'absolute', 
13
        top: '100px', 
14
        left: '100px'
15
    };
16
​
17
    const colorStyle = {
18
        color: '#1C1F23'
19
    };
20
​
21
    const renderLogo = () => {
22
        return (
23
            <img src='https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/semi_logo.svg' alt='semi_logo' style={{ width: '87px', height: '31px' }}/>
24
        );
25
    };
26
​
27
    const imgList = [
28
        'https://lf3-static.bytednsdoc.com/obj/eden-cn/hjeh7pldnulm/SemiDocs/bg-1.png',
Show Error
Auto Save

动画效果与切换速度 ​

通过给 animation 属性控制动画,可选值有 fade,slide
通过给 speed 属性控制两张图片之间的切换时间,单位为ms

0px x 0px
demoApp.vue
demo.tsx
tsconfig.json
Import Map
xxxxxxxxxx
11
7
62
 
1
import { Carousel, Typography, Space } from '@kousum/semi-ui-vue';
2
​
3
export default () => {
4
    const { Title, Paragraph } = Typography;
5
​
6
    const style = {
7
        width: '100%',
8
        height: '400px',
9
    };
10
​
11
    const titleStyle = { 
12
        position: 'absolute', 
13
        top: '100px', 
14
        left: '100px'
15
    };
16
​
17
    const colorStyle = {
18
        color: '#1C1F23'
19
    };
20
​
21
    const renderLogo = () => {
22
        return (
23
            <img src='https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/semi_logo.svg' alt='semi_logo' style={{ width: '87px', height: '31px' }}/>
24
        );
25
    };
26
​
27
​
28
    const imgList = [
Show Error
Auto Save

受控的轮播图 ​

0px x 0px
demoApp.vue
demo.tsx
tsconfig.json
Import Map
xxxxxxxxxx
11
7
76
 
1
import { Carousel, Space, Typography } from '@kousum/semi-ui-vue';
2
import { defineComponent, reactive } from 'vue';
3
​
4
​
5
const CarouselDemo = defineComponent(() => {
6
​
7
  const imgList = [
8
    'https://lf3-static.bytednsdoc.com/obj/eden-cn/hjeh7pldnulm/SemiDocs/bg-1.png',
9
    'https://lf3-static.bytednsdoc.com/obj/eden-cn/hjeh7pldnulm/SemiDocs/bg-2.png',
10
    'https://lf3-static.bytednsdoc.com/obj/eden-cn/hjeh7pldnulm/SemiDocs/bg-3.png',
11
  ];
12
  const textList = [
13
    ['Semi 设计管理系统', '从 Semi Design,到 Any Design', '快速定制你的设计系统,并应用在设计稿和代码中'],
14
    ['Semi 物料市场', '面向业务场景的定制化组件,支持线上预览和调试', '内容由 Semi Design 用户共建'],
15
    ['Semi 设计/代码模板', '高效的 Design2Code 设计稿转代码', '海量 Figma 设计模板一键转为真实前端代码'],
16
  ];
17
  const state = reactive({
18
    activeIndex: 0,
19
  });
20
​
21
  function renderLogo() {
22
    return (
23
      <img src='https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/semi_logo.svg'
24
           alt='semi_logo' style={{ width: '87px', height: '31px' }} />
25
    );
26
  };
27
​
28
  function onChange(activeIndex) {
Show Error
Auto Save

API 参考 ​

Carousel

属性说明类型默认值版本
activeIndex受控属性number-2.10.0
animation切换动画,可选值:fade,slide"fade" | "slide""slide"2.10.0
arrowProps箭头参数,用于自定义箭头样式和点击事件() => { leftArrow: ArrowButton, rightArrow: ArrowButton } -2.10.0
autoPlay是否自动循环展示,或者传入 { interval: 自动切换时间间隔(默认: 2000), hoverToPause: 鼠标悬浮时是否暂停自动切换(默认: true) } boolean | { interval?: number, hoverToPause?: boolean }true2.10.0
className样式类名string-2.10.0
defaultActiveIndex初始化时默认展示的索引number02.10.0
indicatorPosition指示器位置,可选值有: left、center、right"left" | "center" | "right""center"2.10.0
indicatorSize指示器尺寸,可选值有: small、medium"small" | "medium""small"2.10.0
indicatorType指示器类型,可选值有: dot、line、columnar"dot" | "line" | "columnar""dot"2.10.0
theme指示器和箭头主题,可选值有: primary、light、dark"primary" | "light" | "dark""light"2.10.0
onChange图片切换时的回调(index: number, preIndex: number) => void-2.10.0
arrowType箭头展示时机,可选值有: hover、always"hover" | "always"always2.10.0
showArrow是否展示箭头booleantrue2.10.0
showIndicator是否展示指示器booleantrue2.10.0
slideDirection动画效果为slide时的滑动的方向,可选值有: left、right"left" | "right""left"2.10.0
speed切换速度,单位msnumber3002.10.0
style内联样式CSSProperties-2.10.0
trigger指示器触发的时机,可选值有: hover、click"hover" | "click"-2.10.0

ArrowButton

属性说明类型默认值版本
props箭头div上的可传参数,包括style, onClick事件等React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>-2.10.0
children箭头自定义IconReact.ReactNode-2.10.0

Methods ​

绑定在组件实例上的方法,可以通过 ref 调用实现某些特殊交互

方法说明版本
play()播放2.10.0
stop()停止播放2.10.0
goTo(targetIndex)切换到指定位置2.10.0
prev()切换到上一位置2.10.0
next()切换到下一位置2.10.0

设计变量 ​

color
width
height
radius
spacing
animation
变量默认值用法
$color-carousel_indicator_theme_dark-bg-defaultrgba(var(--semi-black), .5)深色主题指示器背景颜色 - 默认
$color-carousel_indicator_theme_dark-bg-hoverrgba(var(--semi-black), .7)深色主题指示器背景颜色 - 悬浮
$color-carousel_indicator_theme_dark-bg-activergba(var(--semi-black), 1)深色主题指示器背景颜色 - 选中
$color-carousel_indicator_theme_primary-bg-defaultrgba(var(--semi-blue-6), .4)主要主题指示器背景颜色 - 默认
$color-carousel_indicator_theme_primary-bg-hoverrgba(var(--semi-blue-6), .7)主要主题指示器背景颜色 - 悬浮
$color-carousel_indicator_theme_primary-bg-activergba(var(--semi-blue-6), 1)主要主题指示器背景颜色 - 选中
$color-carousel_indicator_theme_light-bg-defaultrgba(var(--semi-white), .4)浅色主题指示器背景颜色 - 默认
$color-carousel_indicator_theme_light-bg-hoverrgba(var(--semi-white), .7)浅色主题指示器背景颜色 - 悬浮
$color-carousel_indicator_theme_light-bg-activergba(var(--semi-white), 1)浅色主题指示器背景颜色 - 选中
$color-carousel_arrow_theme_dark-bg-defaultrgba(var(--semi-black), .5)深色主题箭头背景颜色 - 默认
显示第 1 条-第 10 条,共 15 条
  • 1
  • 2
变量默认值用法
$width-carousel_indicator_line240px条状指示器最大宽度
$width-carousel_indicator_columnar_small4px小尺寸柱状指示器宽度
$width-carousel_indicator_columnar_medium6px中等尺寸柱状指示器宽度
$width-carousel_indicator_dot_small8px小尺寸点状指示器宽度
$width-carousel_indicator_dot_medium12px中等尺寸点状指示器宽度
$width-carousel_arrow32px箭头宽度
显示第 1 条-第 6 条,共 6 条
  • 1
变量默认值用法
$height-carousel_indicator_columnar_small_default12px小尺寸柱状指示器高度 - 默认
$height-carousel_indicator_columnar_small_active20px小尺寸柱状指示器高度 - 选中
$height-carousel_indicator_columnar_medium_default20px中等尺寸柱状指示器高度 - 默认
$height-carousel_indicator_columnar_medium_active28px中等尺寸柱状指示器高度 - 选中
$height-carousel_indicator_line_small4px小尺寸条状指示器高度
$height-carousel_indicator_line_medium6px中等尺寸条状指示器高度
显示第 1 条-第 6 条,共 6 条
  • 1
变量默认值用法
$radius-carousel_indicator_dot50%点状指示器圆角
显示第 1 条-第 1 条,共 1 条
  • 1
变量默认值用法
$spacing-carousel_indicator-padding32px指示器内边距
$spacing-carousel_indicator_columnar-marginX4px柱状指示器水平外边距
$spacing-carousel_indicator_line-marginX4px条状指示器水平外边距
$spacing-carousel_indicator_dot-marginX8px点状指示器水平外边距
$spacing-carousel_arrow-left20px左侧箭头绝对定位 - left
$spacing-carousel_arrow-right20px右侧箭头绝对定位 - right
显示第 1 条-第 6 条,共 6 条
  • 1
变量默认值用法
$transition_duration_carousel_indicator-bgvar(--semi-transition_delay-none)指示器-背景色-动画持续时间
$transition_function_carousel_indicator-bgvar(--semi-transition_function-easeOut)指示器-背景色-过渡曲线
$transition_delay_carousel_indicator-bgvar(--semi-transition_delay-none)指示器-背景色-延迟时间
$transition_duration_carousel_arrow-bgvar(--semi-transition_delay-none)箭头-背景色-动画持续时间
$transition_funciton_carousel_arrow-bgvar(--semi-transition_function-easeOut)箭头-背景色-过渡曲线
$transition_delay_carousel_arrow-bgvar(--semi-transition_delay-none)箭头-背景色-延迟时间
显示第 1 条-第 6 条,共 6 条
  • 1
Pager
Next pageIntroduction 介绍