Files
heroui-vue/apps/docs/demos/list-box-custom-styles.vue
T

59 lines
1.4 KiB
Vue

<script setup lang="ts">
import {
Avatar,
AvatarImage,
AvatarFallback,
Description,
Label,
ListBox,
ListBoxItem,
ListBoxItemIndicator,
Surface,
} from "@heroui-vue/components";
const users = [
{
id: "1",
name: "Bob",
email: "bob@heroui.com",
src: "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
},
{
id: "2",
name: "Fred",
email: "fred@heroui.com",
src: "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
},
{
id: "3",
name: "Martha",
email: "martha@heroui.com",
src: "https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
},
];
</script>
<template>
<ListBox
:items="users.slice(0, 2)"
v-slot="{ item: user }"
aria-label="负责人"
selection-mode="single"
class="w-56 rounded-xl border border-border/80 bg-surface p-1 shadow-sm"
>
<ListBoxItem
:id="user.id"
:text-value="user.name"
class="rounded-lg data-[focused=true]:bg-accent/10 data-[selected=true]:bg-accent/5"
>
<Avatar size="sm">
<AvatarImage :alt="user.name" :src="user.src" />
<AvatarFallback>{{ user.name[0] }}</AvatarFallback>
</Avatar>
<div class="flex flex-col">
<Label>{{ user.name }}</Label>
<Description>{{ user.email }}</Description>
</div>
<ListBoxItemIndicator />
</ListBoxItem>
</ListBox>
</template>