Skip to content
ui8kit

component / components

Bulk Bar

Bulk Bar component

Install

npx ui8kit add bulk-bar

Pulls in: box, button, compose, inline, kit-box, kit-button, kit-text, lucide-icon, utils

Preview

No static preview for this item: it needs content or a parent that this page cannot supply. The code is below.

Code

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdn
npx ui8kit add bulk-bar
components/bulk-bar.svelte
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  The "N selected" bar of a list: a count, a clear button and the bulk actions (children). All text comes in
  through props.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type BulkBarProps = {
    label: string;
    clearLabel: string;
    class?: string;
    children?: Snippet;
    onclear?: () => void;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Button from "../compose/Button.svelte";
  import Inline from "../compose/Inline.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import { cn } from "../utils";

  let { label, clearLabel, class: className, children, onclear }: BulkBarProps = $props();
</script>

<Box
  class={cn(
    "flex flex-wrap items-center gap-2 rounded bg-foreground px-4 py-2 text-xs font-bold text-background",
    className
  )}
  role="region"
  aria-label={label}
  aria-live="polite"
  data-slot="bulk-bar"
>
  <Button
    variant="ghost"
    size="sm"
    layout="icon"
    type="button"
    aria-label={clearLabel}
    class="text-background hover:bg-background/15 hover:text-background"
    onclick={() => onclear?.()}
  >
    <LucideIcon name="x" size={16} />
  </Button>
  <Inline data-slot="bulk-count">
    {label}
  </Inline>
  <Inline class="ml-auto flex flex-wrap items-center gap-2">
    {@render children?.()}
  </Inline>
</Box>

Svelte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdn
npx ui8kit add bulk-bar
components/bulk-bar.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * The "N selected" bar of a list: a count, a clear button and the bulk actions (children). All text comes in
 * through props.
 */
import { type ReactNode } from "react";
import { Box, Button, Inline } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { cn } from "../utils";

export type BulkBarProps = {
  label: string;
  clearLabel: string;
  className?: string;
  children?: ReactNode;
  onClear?: () => void;
};

export function BulkBar({ label, clearLabel, className, children, onClear }: BulkBarProps) {
  return (
    <Box
      className={cn(
        "flex flex-wrap items-center gap-2 rounded bg-foreground px-4 py-2 text-xs font-bold text-background",
        className
      )}
      role="region"
      aria-label={label}
      aria-live="polite"
      data-slot="bulk-bar"
    >
      <Button
        variant="ghost"
        size="sm"
        layout="icon"
        type="button"
        aria-label={clearLabel}
        className="text-background hover:bg-background/15 hover:text-background"
        onClick={() => onClear?.()}
      >
        <LucideIcon name="x" size={16} />
      </Button>
      <Inline data-slot="bulk-count">
        {label}
      </Inline>
      <Inline className="ml-auto flex flex-wrap items-center gap-2">
        {children}
      </Inline>
    </Box>
  );
}

React registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdn
npx ui8kit add bulk-bar
components/bulk-bar.vue
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  The "N selected" bar of a list: a count, a clear button and the bulk actions (children). All text comes in
  through props.
-->
<script lang="ts">
export type BulkBarProps = {
  label: string;
  clearLabel: string;
  class?: string;
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import Button from "../compose/Button.vue";
import Inline from "../compose/Inline.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import { cn } from "../utils";

const { label, clearLabel, class: className } = defineProps<BulkBarProps>();
const emit = defineEmits<{ clear: [] }>();
defineSlots<{ default?(): unknown }>();
</script>

<template>
  <Box
    :class="cn(
      'flex flex-wrap items-center gap-2 rounded bg-foreground px-4 py-2 text-xs font-bold text-background',
      className
    )"
    role="region"
    :aria-label="label"
    aria-live="polite"
    data-slot="bulk-bar"
  >
    <Button
      variant="ghost"
      size="sm"
      layout="icon"
      type="button"
      :aria-label="clearLabel"
      class="text-background hover:bg-background/15 hover:text-background"
      @click="() => emit('clear')"
    >
      <LucideIcon name="x" :size="16" />
    </Button>
    <Inline data-slot="bulk-count">
      {{ label }}
    </Inline>
    <Inline class="ml-auto flex flex-wrap items-center gap-2">
      <slot />
    </Inline>
  </Box>
</template>

Vue registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdn
npx ui8kit add bulk-bar
components/bulk-bar.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * The "N selected" bar of a list: a count, a clear button and the bulk actions (children). All text comes in
 * through props.
 */
import { type JSX } from "solid-js";
import { Box, Button, Inline } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { cn } from "../utils";

export type BulkBarProps = {
  label: string;
  clearLabel: string;
  class?: string;
  children?: JSX.Element;
  onClear?: () => void;
};

export function BulkBar({ label, clearLabel, class: className, children, onClear }: BulkBarProps) {
  return (
    <Box
      class={cn(
        "flex flex-wrap items-center gap-2 rounded bg-foreground px-4 py-2 text-xs font-bold text-background",
        className
      )}
      role="region"
      aria-label={label}
      aria-live="polite"
      data-slot="bulk-bar"
    >
      <Button
        variant="ghost"
        size="sm"
        layout="icon"
        type="button"
        aria-label={clearLabel}
        class="text-background hover:bg-background/15 hover:text-background"
        onClick={() => onClear?.()}
      >
        <LucideIcon name="x" size={16} />
      </Button>
      <Inline data-slot="bulk-count">
        {label}
      </Inline>
      <Inline class="ml-auto flex flex-wrap items-center gap-2">
        {children}
      </Inline>
    </Box>
  );
}

Solid registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdn
npx ui8kit add bulk-bar
blocks/bulk-bar.templ
// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/parts/bulk-bar.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/box"
	"github.com/ui8kit/codegen/generated/templ/ui/button"
	"github.com/ui8kit/codegen/generated/templ/compose"
	"github.com/ui8kit/codegen/generated/templ/icons"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// BulkBarProps are the props of BulkBar; the values are the JSON shapes of the TypeScript props.
type BulkBarProps struct {
	Label any `json:"label"`
	ClearLabel any `json:"clearLabel"`
	Class string `json:"className"`
}

// The "N selected" bar of a list: a count, a clear button and the bulk actions (children). All text comes in through props.
templ BulkBar(p BulkBarProps) {
	{{ vLabel := p.Label }}
	{{ vClearLabel := p.ClearLabel }}
	@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("flex flex-wrap items-center gap-2 rounded bg-foreground px-4 py-2 text-xs font-bold text-background", p.Class)), Attrs: uiutils.Attrs("role", "region", "aria-label", vLabel, "aria-live", "polite", "data-slot", "bulk-bar")}}) {
		@compose.Button(compose.ButtonProps{Variant: "ghost", Size: "sm", Layout: "icon", ButtonProps: button.ButtonProps{Type: "button", AriaLabel: uiutils.S(vClearLabel), Class: "text-background hover:bg-background/15 hover:text-background"}}) {
			@icons.LucideIcon(icons.LucideIconProps{Name: "x", Size: 16})
		}
		@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Attrs: uiutils.Attrs("data-slot", "bulk-count")}}) {
			{ uiutils.Text(vLabel) }
		}
		@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "ml-auto flex flex-wrap items-center gap-2"}}) {
			{ children... }
		}
	}
}

templ registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdn
npx ui8kit add bulk-bar
blocks/bulk-bar.html.twig
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/parts/bulk-bar.json
    The "N selected" bar of a list: a count, a clear button and the bulk actions (children). All text comes in through props.
    Props (p): label, clearLabel, className; children: markup. -#}
{%- set v_label = (p.label ?? null) -%}
{%- set v_clearLabel = (p.clearLabel ?? null) -%}
{%- set c_4 -%}
  {%- set c_1 -%}
    {{ include('icons/LucideIcon.html.twig', {'name': 'x', 'size': 16}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Button.html.twig', {'variant': 'ghost', 'size': 'sm', 'layout': 'icon', 'type': 'button', 'ariaLabel': og_s(v_clearLabel), 'class': 'text-background hover:bg-background/15 hover:text-background', 'children': c_1}, with_context = false) }}
  {%- set c_2 -%}
    {{ og_text(v_label) }}
  {%- endset -%}
  {{ include('compose/Inline.html.twig', {'attrs': og_attrs(['data-slot', 'bulk-count']), 'children': c_2}, with_context = false) }}
  {%- set c_3 -%}
    {{ og_slot((children ?? null))|raw }}
  {%- endset -%}
  {{ include('compose/Inline.html.twig', {'class': 'ml-auto flex flex-wrap items-center gap-2', 'children': c_3}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s(og_cnv(['flex flex-wrap items-center gap-2 rounded bg-foreground px-4 py-2 text-xs font-bold text-background', (p.className ?? '')])), 'attrs': og_attrs(['role', 'region', 'aria-label', v_label, 'aria-live', 'polite', 'data-slot', 'bulk-bar']), 'children': c_4}, with_context = false) }}

Twig registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdn
npx ui8kit add bulk-bar
blocks/bulk-bar.latte
{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/parts/bulk-bar.json
    The "N selected" bar of a list: a count, a clear button and the bulk actions (children). All text comes in through props.
    Props (p): label, clearLabel, className; children: markup. *}
{var $v_label = ($p['label'] ?? null)}
{var $v_clearLabel = ($p['clearLabel'] ?? null)}
{capture $c_4}
  {capture $c_1}
    {=og_include('icons/LucideIcon.latte', ['name' => 'x', 'size' => 16])|noescape}
  {/capture}
  {=og_include('compose/Button.latte', ['variant' => 'ghost', 'size' => 'sm', 'layout' => 'icon', 'type' => 'button', 'ariaLabel' => og_s($v_clearLabel), 'class' => 'text-background hover:bg-background/15 hover:text-background', 'children' => (string) $c_1])|noescape}
  {capture $c_2}
    {=og_text($v_label)}
  {/capture}
  {=og_include('compose/Inline.latte', ['attrs' => og_attrs(['data-slot', 'bulk-count']), 'children' => (string) $c_2])|noescape}
  {capture $c_3}
    {=og_slot(($children ?? null))|noescape}
  {/capture}
  {=og_include('compose/Inline.latte', ['class' => 'ml-auto flex flex-wrap items-center gap-2', 'children' => (string) $c_3])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s(og_cnv(['flex flex-wrap items-center gap-2 rounded bg-foreground px-4 py-2 text-xs font-bold text-background', ($p['className'] ?? '')])), 'attrs' => og_attrs(['role', 'region', 'aria-label', $v_label, 'aria-live', 'polite', 'data-slot', 'bulk-bar']), 'children' => (string) $c_4])|noescape}

Latte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdn
npx ui8kit add bulk-bar
blocks/bulk-bar.html.j2
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/parts/bulk-bar.json
    The "N selected" bar of a list: a count, a clear button and the bulk actions (children). All text comes in through props.
    Props (p): label, clearLabel, className; children: markup. -#}
{%- set v_label = og_def(p['label'], none) -%}
{%- set v_clearLabel = og_def(p['clearLabel'], none) -%}
{%- set c_4 -%}
  {%- set c_1 -%}
    {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'x', 'Size': 16}}) }}
  {%- endset -%}
  {{ og_include('compose/button.html.j2', {'p': {'Variant': 'ghost', 'Size': 'sm', 'Layout': 'icon', 'Type': 'button', 'AriaLabel': og_s(v_clearLabel), 'Class': 'text-background hover:bg-background/15 hover:text-background'}, 'children': c_1}) }}
  {%- set c_2 -%}
    {{ og_text(v_label) }}
  {%- endset -%}
  {{ og_include('compose/inline.html.j2', {'p': {'Attrs': og_attrs(['data-slot', 'bulk-count'])}, 'children': c_2}) }}
  {%- set c_3 -%}
    {{ og_slot(og_def(children, none))|safe }}
  {%- endset -%}
  {{ og_include('compose/inline.html.j2', {'p': {'Class': 'ml-auto flex flex-wrap items-center gap-2'}, 'children': c_3}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(og_cnv(['flex flex-wrap items-center gap-2 rounded bg-foreground px-4 py-2 text-xs font-bold text-background', og_def(p['className'], '')])), 'Attrs': og_attrs(['role', 'region', 'aria-label', v_label, 'aria-live', 'polite', 'data-slot', 'bulk-bar'])}, 'children': c_4}) }}

Jinja2 registry item (JSON)

Props

Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.

The "N selected" bar of a list: a count, a clear button and the bulk actions (children). All text comes in through props.

Props of BulkBar
PropTypeDefault Description
label (required)string-the count, e.g. "3 selected"
clearLabel (required)string-accessible name of the clear button