Skip to content

列表 List

通用列表

何时使用

  • 最基础的列表展示,可承载文字、列表、图片、段落,链接等

基本使用

Composed UI Title 1

Composed UI, A Composed Vue3 UI Components Library.

Composed UI Title 2

Composed UI, A Composed Vue3 UI Components Library.

Composed UI Title 3

Composed UI, A Composed Vue3 UI Components Library.

Composed UI Title 4

Composed UI, A Composed Vue3 UI Components Library.
Show Code
vue
<script setup lang="ts">
import { ref } from 'vue'
const listData = ref([
  {
    title: 'Composed UI Title 1',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 2',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 3',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 4',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  }
])
</script>
<template>
  <List>
    <ListItem v-for="(data, index) in listData" :key="index" :title="data.title">
      <template #avatar>
        <Avatar src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg" />
      </template>
      <template #description>
        {{ data.description }}
      </template>
    </ListItem>
  </List>
</template>

隐藏分割线

Composed UI Title 1

Composed UI, A Composed Vue3 UI Components Library.

Composed UI Title 2

Composed UI, A Composed Vue3 UI Components Library.

Composed UI Title 3

Composed UI, A Composed Vue3 UI Components Library.

Composed UI Title 4

Composed UI, A Composed Vue3 UI Components Library.
Show Code
vue
<script setup lang="ts">
import { ref } from 'vue'
const listData = ref([
  {
    title: 'Composed UI Title 1',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 2',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 3',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 4',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  }
])
</script>
<template>
  <List :split="false">
    <ListItem v-for="(data, index) in listData" :key="index" :title="data.title">
      <template #avatar>
        <Avatar src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg" />
      </template>
      <template #description>
        {{ data.description }}
      </template>
    </ListItem>
  </List>
</template>

带边框列表

bordered:
Header

Composed UI Title 1

Composed UI, A Composed Vue3 UI Components Library.

Composed UI Title 2

Composed UI, A Composed Vue3 UI Components Library.

Composed UI Title 3

Composed UI, A Composed Vue3 UI Components Library.

Composed UI Title 4

Composed UI, A Composed Vue3 UI Components Library.
Show Code
vue
<script setup lang="ts">
import { ref } from 'vue'
const listData = ref([
  {
    title: 'Composed UI Title 1',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 2',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 3',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 4',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  }
])
const bordered = ref(true)
</script>
<template>
  <Flex vertical>
    <Space align="center">
      bordered:<Switch v-model="bordered" />
    </Space>
    <List :bordered="bordered">
      <template #header>
        <div>Header</div>
      </template>
      <ListItem v-for="(data, index) in listData" :key="index" :title="data.title">
        <template #avatar>
          <Avatar src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg" />
        </template>
        <template #description>
          {{ data.description }}
        </template>
      </ListItem>
      <template #footer>
        <div>Footer</div>
      </template>
    </List>
  </Flex>
</template>

三种尺寸

small
middle
large
Show Code
vue
<script setup lang="ts">
import { ref } from 'vue'
const simpleListData = ref([
  {
    title: 'Composed UI Title 1',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 2',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 3',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 4',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  }
])
const simpleList = ref([
  'Composed UI is developed using TypeScript',
  'A Composed Vue3 UI Components Library',
  'Streamline web development withCompose UI',
  'Incredible Vue components for modern web design',
  'Transform your Vue interface withCompose UI'
])
const sizeOptions = [
  {
    label: 'small',
    value: 'small'
  },
  {
    label: 'middle',
    value: 'middle'
  },
  {
    label: 'large',
    value: 'large'
  }
]
const size = ref('middle')
</script>
<template>
  <Flex vertical>
    <Radio :options="sizeOptions" v-model:value="size" button button-style="solid" />
    <Row :gutter="32">
      <Col :span="12">
        <List bordered :size="size">
          <ListItem v-for="(data, index) in simpleListData" :key="index">
            <template #avatar>
              <Avatar src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg" />
            </template>
            <template #title>
              <a href="https://Kitesource.github.io/composed-ui/">{{ data.title }}</a>
            </template>
            <template #description>
              {{ data.description }}
            </template>
          </ListItem>
        </List>
      </Col>
      <Col :span="12">
        <List bordered :size="size">
          <template #header>
            <div>Header</div>
          </template>
          <ListItem v-for="(data, index) in simpleList" :key="index">
            {{ data }}
          </ListItem>
          <template #footer>
            <div>Footer</div>
          </template>
        </List>
      </Col>
    </Row>
  </Flex>
</template>

加载中

Loading state:
Show Code
vue
<script setup lang="ts">
import { ref } from 'vue'
const simpleListData = ref([
  {
    title: 'Composed UI Title 1',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 2',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 3',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 4',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  }
])
const simpleList = ref([
  'Composed UI is developed using TypeScript',
  'A Composed Vue3 UI Components Library',
  'Streamline web development withCompose UI',
  'Incredible Vue components for modern web design',
  'Transform your Vue interface withCompose UI'
])
const loading = ref(true)
</script>
<template>
  <Flex vertical>
    <Space align="center"> Loading state:<Switch v-model="loading" /> </Space>
    <Row :gutter="32">
      <Col :span="12">
        <List bordered :loading="loading">
          <ListItem v-for="(data, index) in simpleListData" :key="index" :title="data.title">
            <template #avatar>
              <Avatar src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg" />
            </template>
            <template #description>
              {{ data.description }}
            </template>
          </ListItem>
        </List>
      </Col>
      <Col :span="12">
        <List bordered :loading="loading" :spin-props="{ indicator: 'dynamic-circle' }">
          <template #header>
            <div>Header</div>
          </template>
          <ListItem v-for="(data, index) in simpleList" :key="index">
            {{ data }}
          </ListItem>
          <template #footer>
            <div>Footer</div>
          </template>
        </List>
      </Col>
    </Row>
  </Flex>
</template>

暂无数据

暂无数据

Show Code
vue
<template>
  <List>
    <ListItem v-for="(data, index) in []" :key="index"></ListItem>
  </List>
</template>

显示悬浮样式

Show Code
vue
<script setup lang="ts">
import { ref } from 'vue'
const simpleListData = ref([
  {
    title: 'Composed UI Title 1',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 2',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 3',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 4',
    description: 'A Composed Vue3 UI Components Library.',
    content: 'content'
  }
])
const simpleList = ref([
  'Composed UI is developed using TypeScript',
  'A Composed Vue3 UI Components Library',
  'Streamline web development withCompose UI',
  'Incredible Vue components for modern web design',
  'Transform your Vue interface withCompose UI'
])
</script>
<template>
  <Row :gutter="32">
    <Col :span="12">
      <List bordered hoverable>
        <ListItem v-for="(data, index) in simpleListData" :key="index" :title="data.title">
          <template #avatar>
            <Avatar src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg" />
          </template>
          <template #description>
            {{ data.description }}
          </template>
        </ListItem>
      </List>
    </Col>
    <Col :span="12">
      <List bordered hoverable>
        <template #header>
          <div>Header</div>
        </template>
        <ListItem v-for="(data, index) in simpleList" :key="index">
          {{ data }}
        </ListItem>
        <template #footer>
          <div>Footer</div>
        </template>
      </List>
    </Col>
  </Row>
</template>

列表添加操作项

Composed UI Title 1

Composed UI, A Composed Vue3 UI Components Library.
content

Composed UI Title 2

Composed UI, A Composed Vue3 UI Components Library.
content

Composed UI Title 3

Composed UI, A Composed Vue3 UI Components Library.
content

Composed UI Title 4

Composed UI, A Composed Vue3 UI Components Library.
content
Show Code
vue
<script setup lang="ts">
import { ref } from 'vue'
const listData = ref([
  {
    title: 'Composed UI Title 1',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 2',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 3',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 4',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  }
])
</script>
<template>
  <List>
    <ListItem v-for="(data, index) in listData" :key="index" :title="data.title">
      <template #avatar>
        <Avatar src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg" />
      </template>
      <template #description>
        {{ data.description }}
      </template>
      {{ data.content }}
      <template #actions>
        <a>edit</a>
        <a>more</a>
      </template>
    </ListItem>
  </List>
</template>

自定义样式

Composed UI Title 1

Composed UI, A Composed Vue3 UI Components Library.
content
extra

Composed UI Title 2

Composed UI, A Composed Vue3 UI Components Library.
content
extra

Composed UI Title 3

Composed UI, A Composed Vue3 UI Components Library.
content
extra

Composed UI Title 4

Composed UI, A Composed Vue3 UI Components Library.
content
extra
Show Code
vue
<script setup lang="ts">
import { ref, h } from 'vue'
import { UserOutlined } from '@ant-design/icons-vue'
const listData = ref([
  {
    title: 'Composed UI Title 1',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 2',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 3',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  },
  {
    title: 'Composed UI Title 4',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'content'
  }
])
</script>
<template>
  <List>
    <ListItem
      :avatar-props="{
        icon: () => h(UserOutlined),
        size: 56
      }"
      :avatar-style="{ alignSelf: 'center' }"
      :title-style="{ fontSize: '20px' }"
      :description-style="{ fontSize: '16px' }"
      :content-style="{ fontSize: '18px', color: '#f50', marginLeft: '16px' }"
      :extra-style="{ overflow: 'hidden', borderRadius: '12px' }"
      v-for="(data, index) in listData"
      :key="index"
      :title="data.title"
    >
      <template #description>
        {{ data.description }}
      </template>
      {{ data.content }}
      <template #actions>
        <a>edit</a>
        <a>more</a>
      </template>
      <template #extra>
        <img
          class="extra-img"
          width="200"
          alt="extra"
          src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/2.jpg"
        />
      </template>
    </ListItem>
  </List>
</template>

竖排分页列表

Composed UI part 1

Composed UI, A Composed Vue3 UI Components Library.
Composed UI supplies streamline web development, incredible Vue components for modern web design and transform your Vue interface completely.
156 156 6
extra

Composed UI part 2

Composed UI, A Composed Vue3 UI Components Library.
Composed UI supplies streamline web development, incredible Vue components for modern web design and transform your Vue interface completely.
156 156 6
extra

Composed UI part 3

Composed UI, A Composed Vue3 UI Components Library.
Composed UI supplies streamline web development, incredible Vue components for modern web design and transform your Vue interface completely.
156 156 6
extra
1 23
Show Code
vue
<script setup lang="ts">
import { ref } from 'vue'
import { StarOutlined, LikeOutlined, MessageOutlined } from '@ant-design/icons-vue'
const allListData = ref<any[]>([])
for (let i = 1; i <= 8; i++) {
  allListData.value.push({
    href: 'https://Kitesource.github.io/composed-ui/',
    title: `Composed UI part ${i}`,
    avatar: 'https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg',
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content:
      'Composed UI supplies streamline web development, incredible Vue components for modern web design and transform your Vue interface completely.'
  })
}
const paginationListData = ref<any[]>([])
paginationListData.value = allListData.value.slice(0, 3)
const pagination = {
  page: 1,
  pageSize: 3,
  total: 8,
  onChange: (page: number, pageSize: number) => {
    console.log('change page', page)
    console.log('change pageSize', pageSize)
    const start = (page - 1) * pageSize + 1
    const end = page * pageSize > 8 ? 8 : page * pageSize
    paginationListData.value = allListData.value.slice(start - 1, end)
  }
}
</script>
<template>
  <List vertical size="large" show-pagination :pagination="pagination">
    <ListItem v-for="(data, index) in paginationListData" :key="index">
      <template #title>
        <a :href="data.href" target="_blank">{{ data.title }}</a>
      </template>
      <template #avatar>
        <Avatar src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg" />
      </template>
      <template #description>
        {{ data.description }}
      </template>
      {{ data.content }}
      <template #actions>
        <span>
          <StarOutlined style="margin-right: 8px" />156
        </span>
        <span>
          <LikeOutlined style="margin-right: 8px" />156
        </span>
        <span>
          <MessageOutlined style="margin-right: 8px" />6
        </span>
      </template>
      <template #extra>
        <img
          class="extra-img"
          width="272"
          alt="extra"
          src="https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png"
        />
      </template>
    </ListItem>
    <template #footer>
      <div>
        <b>Composed UI</b>
        footer part
      </div>
    </template>
  </List>
</template>
<style lang="less" scoped>
.extra-img {
  display: inline-block;
  vertical-align: bottom;
}
</style>

列表配置器

list header

Composed UI Title 1

Composed UI, A Composed Vue3 UI Components Library.
Incredible Vue components for modern web design
extra

Composed UI Title 2

Composed UI, A Composed Vue3 UI Components Library.
Incredible Vue components for modern web design
extra

Composed UI Title 3

Composed UI, A Composed Vue3 UI Components Library.
Incredible Vue components for modern web design
extra

Composed UI Title 4

Composed UI, A Composed Vue3 UI Components Library.
Incredible Vue components for modern web design
extra

Composed UI Title 5

Composed UI, A Composed Vue3 UI Components Library.
Incredible Vue components for modern web design
extra
1-5 of 30 items 1 23456 跳至
Show Code
vue
<script setup lang="ts">
import { ref, reactive } from 'vue'
const allConfigListData = ref<any[]>([])
for (let i = 1; i <= 30; i++) {
  allConfigListData.value.push({
    href: 'https://Kitesource.github.io/composed-ui/',
    title: `Composed UI Title ${i}`,
    description: 'Composed UI, A Composed Vue3 UI Components Library.',
    content: 'Incredible Vue components for modern web design'
  })
}
const configListData = ref<any[]>([])
configListData.value = allConfigListData.value.slice(0, 5)
const state = reactive({
  bordered: true,
  vertical: false,
  split: true,
  size: 'middle',
  loading: false,
  hoverable: true,
  header: 'list header',
  footer: 'list footer',
  extra: 'extra',
  showPagination: true,
  pagination: {
    page: 1,
    pageSize: 5,
    total: 30,
    showTotal: (total: number, range: number[]) => `${range[0]}-${range[1]} of ${total} items`,
    showSizeChanger: true,
    showQuickJumper: true,
    onChange: (page: number, pageSize: number) => {
      console.log('change page', page)
      console.log('change pageSize', pageSize)
      const start = (page - 1) * pageSize + 1
      const end = page * pageSize > state.pagination.total ? state.pagination.total : page * pageSize
      configListData.value = allConfigListData.value.slice(start - 1, end)
    }
  }
})
</script>
<template>
  <Flex gap="large" vertical>
    <Row :gutter="[24, 12]">
      <Col :span="6">
        <Space gap="small" vertical> bordered:<Switch v-model="state.bordered" /> </Space>
      </Col>
      <Col :span="6">
        <Space gap="small" vertical> vertical:<Switch v-model="state.vertical" /> </Space>
      </Col>
      <Col :span="6">
        <Space gap="small" vertical> split:<Switch v-model="state.split" /> </Space>
      </Col>
      <Col :span="6">
        <Flex gap="small" vertical>
          size:<Select :options="sizeOptions" v-model="state.size" />
        </Flex>
      </Col>
      <Col :span="6">
        <Space gap="small" vertical> loading:<Switch v-model="state.loading" /> </Space>
      </Col>
      <Col :span="6">
        <Space gap="small" vertical> hoverable:<Switch v-model="state.hoverable" /> </Space>
      </Col>
      <Col :span="6">
        <Flex gap="small" vertical> header:<Input v-model:value="state.header" placeholder="header" /> </Flex>
      </Col>
      <Col :span="6">
        <Flex gap="small" vertical> footer:<Input v-model:value="state.footer" placeholder="footer" /> </Flex>
      </Col>
      <Col :span="6">
        <Flex gap="small" vertical> extra:<Input v-model:value="state.extra" placeholder="extra" /> </Flex>
      </Col>
      <Col :span="6">
        <Space gap="small" vertical> showPagination:<Switch v-model="state.showPagination" /> </Space>
      </Col>
      <Col :span="6">
        <Space gap="small" vertical> showSizeChanger:<Switch v-model="state.pagination.showSizeChanger" /> </Space>
      </Col>
      <Col :span="6">
        <Space gap="small" vertical> showQuickJumper:<Switch v-model="state.pagination.showQuickJumper" /> </Space>
      </Col>
    </Row>
    <List
      :bordered="state.bordered"
      :vertical="state.vertical"
      :split="state.split"
      :size="state.size"
      :loading="state.loading"
      :hoverable="state.hoverable"
      :header="state.header"
      :footer="state.footer"
      :showPagination="state.showPagination"
      :pagination="state.pagination"
    >
      <ListItem v-for="(data, index) in configListData" :key="index" :extra="state.extra">
        <template #title>
          <a :href="data.href" target="_blank">{{ data.title }}</a>
        </template>
        <template #avatar>
          <Avatar src="https://cdn.jsdelivr.net/gh/Kitesource/resources@0.0.1/1.jpg" />
        </template>
        <template #description>
          {{ data.description }}
        </template>
        {{ data.content }}
      </ListItem>
    </List>
  </Flex>
</template>

APIs

List

参数说明类型默认值
bordered是否展示边框booleanfalse
vertical是否使用竖直样式booleanfalse
split是否展示分割线booleantrue
size列表尺寸'small' | 'middle' | 'large''middle'
loading是否加载中booleanfalse
hoverable是否显示悬浮样式booleanfalse
header列表头部string | slotundefined
footer列表底部string | slotundefined
spinPropsSpin 组件属性配置,参考 Spin Props,用于配置列表加载中样式object{}
emptyPropsEmpty 组件属性配置,参考 Empty Props,用于配置暂无数据样式object{}
showPagination是否显示分页booleanfalse
paginationPagination 组件属性配置,参考 Pagination Props,用于配置分页功能object{}

ListItem

参数说明类型默认值
avatar列表元素的图标string | slotundefined
avatarPropsAvatar 组件属性配置,参考 Avatar Props,用于配置列表图标样式object{}
title列表元素的标题string | slotundefined
description列表元素的描述内容string | slotundefined
actions列表操作组slotundefined
extra额外内容,展示在列表右侧string | slotundefined
avatarStyle设置图标的样式CSSProperties{}
titleStyle设置标题的样式CSSProperties{}
descriptionStyle设置描述内容的样式CSSProperties{}
contentStyle设置内容的样式CSSProperties{}
actionsStyle设置操作区域的样式CSSProperties{}
extraStyle设置额外内容的样式CSSProperties{}

Slots

List Slots

名称说明类型
header自定义列表头部v-slot:header
default自定义内容v-slot:default
footer自定义列表底部v-slot:footer

ListItem Slots

名称说明类型
avatar自定义列表元素的图标v-slot:avatar
title自定义列表元素的标题v-slot:title
description自定义列表元素的描述内容v-slot:description
default自定义内容v-slot:default
actions自定义列表操作组v-slot:actions
extra自定义额外内容v-slot:extra

Released under the MIT License.