Action bar

Live examples of Action bar, with the exact Vue file that renders each one.

Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz.

Bulk actions

Select rows to show the bar; clear the selection or press Esc in the bar to hide it.

2 connections selected

2 connections selected

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: 'Orders to ERP' },
  { id: 'stock', name: 'Stock from warehouse' },
  { id: 'customers', name: 'Customers to CRM' },
]
const selected = ref<string[]>(['orders', 'stock'])
const status = computed(() => `${selected.value.length} ${selected.value.length === 1 ? 'connection' : 'connections'} selected`)
</script>

<template>
  <div class="flex w-full max-w-120 flex-col gap-(--bh-space-100)">
    <ActionBar
      :open="selected.length > 0"
      :status="status"
      label="Actions for selected connections"
      clear-label="Clear selection"
      @clear="selected = []"
    >
      <Button variant="outline" size="sm"><Pause />Pause</Button>
      <Button variant="outline" size="sm"><Download />Export</Button>
      <Button variant="ghost-destructive" size="sm"><Trash2 />Delete</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>