Thanh thao tác

Ví dụ trực tiếp của Action bar, kèm đúng file Vue tạo ra từng ví dụ.

Mỗi ví dụ là một file Vue hoàn chỉnh. Chép vào app đã cài registry, hoặc mở trong StackBlitz.

Thao tác hàng loạt

Chọn hàng để hiện thanh; bỏ chọn hoặc bấm Esc trong thanh để ẩn.

2 kết nối đã chọn

2 kết nối đã chọn

ActionBarTable.vue
<script setup lang="ts">
import { Download, Pause, Trash2 } from '@lucide/vue'
import { computed, ref } from 'vue'
import { ActionBar } from '@/components/ui/action-bar'
import { Button } from '@/components/ui/button'

const rows = [
  { id: 'orders', name: 'Đơn hàng sang ERP' },
  { id: 'stock', name: 'Tồn kho từ kho' },
  { id: 'customers', name: 'Khách hàng sang CRM' },
]
const selected = ref<string[]>(['orders', 'stock'])
const status = computed(() => `${selected.value.length} kết nối đã chọn`)
</script>

<template>
  <div class="flex w-full max-w-120 flex-col gap-(--bh-space-100)">
    <ActionBar
      :open="selected.length > 0"
      :status="status"
      label="Thao tác cho các kết nối đã chọn"
      clear-label="Bỏ chọn"
      @clear="selected = []"
    >
      <Button variant="outline" size="sm"><Pause />Tạm dừng</Button>
      <Button variant="outline" size="sm"><Download />Xuất</Button>
      <Button variant="ghost-destructive" size="sm"><Trash2 />Xóa</Button>
    </ActionBar>
    <ul class="m-0 list-none p-0">
      <li v-for="row in rows" :key="row.id" class="border-b-(length:--bh-border-width-default) border-(--bh-color-border) py-(--bh-space-100)">
        <label class="flex cursor-pointer items-center gap-(--bh-space-100)">
          <input v-model="selected" type="checkbox" :value="row.id" class="size-(--bh-size-icon-default) accent-(--bh-color-background-primary)">
          {{ row.name }}
        </label>
      </li>
    </ul>
  </div>
</template>