---
title: "Action Bar · UI SDK — StyleX Blocks"
description: "A floating bulk-action toolbar that appears above the page when items are selected."
url: "https://stylexblocks.com/components/ui-sdk/action-bar/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Action Bar

A floating bulk-action toolbar that appears above the page when items are selected.

- Behavior engine: UI SDK
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/action-bar.md), [Base UI](https://stylexblocks.com/components/base-ui/action-bar.md)
- Category: Display
- Used in blocks: [Inbox Table](https://stylexblocks.com/block/ui-sdk/inbox-table.md), [Searchable Table](https://stylexblocks.com/block/ui-sdk/searchable-table.md), [Settings Panels](https://stylexblocks.com/block/ui-sdk/settings-panels.md), [Simple Table](https://stylexblocks.com/block/ui-sdk/simple-table.md), [Tree Table](https://stylexblocks.com/block/ui-sdk/tree-table.md)
- HTML page: https://stylexblocks.com/components/ui-sdk/action-bar/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style ui-sdk
```

Then add the item as source you own:

```sh
npx stylexblocks add action-bar
```

Equivalent: `npx shadcn add @stylexblocks/action-bar`. Registry item JSON: https://stylexblocks.com/r/ui-sdk/action-bar.json

## Usage

```tsx
import { ActionBar } from "#components/ui/ui-sdk/action-bar.tsx";
import { Button } from "#components/ui/ui-sdk/button.tsx";

export function Example({ selection }: { selection: string[] }) {
  if (selection.length === 0) return null;
  return (
    // the positioner fixes the bar over the viewport bottom, above the page —
    // render it only while a selection exists; parts compose via render
    <ActionBar.Positioner>
      <ActionBar.Content>
        <ActionBar.SelectionTrigger>
          {selection.length} selected
        </ActionBar.SelectionTrigger>
        <ActionBar.Separator />
        <Button variant="ghost" size="xs">Download</Button>
        <Button variant="ghost" size="xs">Delete</Button>
      </ActionBar.Content>
    </ActionBar.Positioner>
  );
}
```

## Source

`components/ui/ui-sdk/action-bar.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createSlotRecipeContext } from "#lib/ui-sdk/create-slot-recipe-context.tsx";
import { defineSlotRecipe } from "#lib/recipe-props.ts";
import { zIndices } from "@stylexblocks/ui/tokens/z-indices.stylex.ts";
import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'
import { lineHeights } from '@stylexblocks/ui/tokens/line-heights.stylex.ts'
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { semanticRadii } from '@stylexblocks/ui/semantic-tokens/radii.stylex.ts'
import { semanticShadows } from '@stylexblocks/ui/semantic-tokens/shadows.stylex.ts'
import { sizes } from '@stylexblocks/ui/tokens/sizes.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const actionBarPositioner = stylex.create({
  base: {
    position: 'fixed',
    display: 'flex',
    justifyContent: 'center',
    pointerEvents: 'none',
    insetInline: 0,
    top: 'unset',
    bottom: 'calc(env(safe-area-inset-bottom) + 20px)',
  },
})

const actionBarContent = stylex.create({
  base: {
    backgroundColor: semanticColors.bgPanel,
    boxShadow: semanticShadows.md,
    display: 'flex',
    alignItems: 'center',
    gap: spacing._3,
    borderRadius: semanticRadii.panel,
    paddingBlock: spacing._2_5,
    paddingInline: spacing._3,
    pointerEvents: 'auto',
    translate: 'calc(-1 * var(--scrollbar-width) / 2) 0px',
  },
})

const actionBarSeparator = stylex.create({
  base: {
    width: '1px',
    height: sizes._5,
    backgroundColor: semanticColors.border,
  },
})

const actionBarSelectionTrigger = stylex.create({
  base: {
    display: 'inline-flex',
    alignItems: 'center',
    gap: spacing._2,
    alignSelf: 'stretch',
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.sm,
    paddingInline: spacing._4,
    paddingBlock: spacing._1,
    borderRadius: semanticRadii.control,
    borderWidth: '1px',
    borderStyle: 'dashed',
  },
})

// defineSlotRecipe validates the shape at compile time: default values must
// exist in the axis maps, and slot keys must be `styles` or a declared axis
const actionBarRecipe = defineSlotRecipe({
  slots: {
    positioner: { styles: actionBarPositioner },
    content: { styles: actionBarContent },
    separator: { styles: actionBarSeparator },
    selectionTrigger: { styles: actionBarSelectionTrigger },
  },
  defaultVariants: {},
});

// Local chrome the recipe leaves to the composition layer: a z-index so the
// fixed bar floats above sticky page chrome, a hairline on the panel, and
// the selection chip's dashed border color.
const chrome = stylex.create({
  positioner: {
    zIndex: zIndices.dropdown,
  },
  content: {
    borderWidth: "1px",
    borderStyle: "solid",
    borderColor: semanticColors.border,
  },
  selectionTrigger: {
    borderColor: semanticColors.border,
    color: semanticColors.fgMuted,
  },
});

/**
 * Action Bar — a floating bulk-action toolbar composed from presentational
 * parts: the positioner fixes itself over the viewport bottom (render it
 * only while a selection exists), the content is the floating panel. Every
 * part composes via `render` through UI SDK's `renderElement`.
 */
const { withProvider, withContext } = createSlotRecipeContext(actionBarRecipe);

export const ActionBar = {
  Positioner: withProvider(
    "div",
    () => [actionBarPositioner.base, chrome.positioner],
    "ActionBarPositioner",
  ),
  Content: withContext(
    "div",
    () => [actionBarContent.base, chrome.content],
    "ActionBarContent",
  ),
  SelectionTrigger: withContext(
    "span",
    () => [actionBarSelectionTrigger.base, chrome.selectionTrigger],
    "ActionBarSelectionTrigger",
  ),
  Separator: withContext("div", "separator", "ActionBarSeparator"),
};
```
