BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/diceui/base/action-bar

action-bar

diceui-base/action-bar
FreeComponent

diceui/base publishes no description for this item.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/action-bar.json

Source

ui/action-bar.tsxraw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/action-bar.json · first 6 KB
1"use client";
2
3import { mergeProps } from "@base-ui/react/merge-props";
4import { useRender } from "@base-ui/react/use-render";
5import * as React from "react";
6import * as ReactDOM from "react-dom";
7import { useComposedRefs } from "@/lib/compose-refs";
8import { cn } from "@/lib/utils";
9import { useAsRef } from "@/registry/bases/base/hooks/use-as-ref";
10import { useIsomorphicLayoutEffect } from "@/registry/bases/base/hooks/use-isomorphic-layout-effect";
11import { Button } from "@/registry/bases/base/ui/button";
12import { useDirection } from "@/registry/bases/base/ui/direction";
13
14const ROOT_NAME = "ActionBar";
15const GROUP_NAME = "ActionBarGroup";
16const ITEM_NAME = "ActionBarItem";
17const CLOSE_NAME = "ActionBarClose";
18const SEPARATOR_NAME = "ActionBarSeparator";
19const ITEM_SELECT = "actionbar.itemSelect";
20const ENTRY_FOCUS = "actionbarFocusGroup.onEntryFocus";
21const EVENT_OPTIONS = { bubbles: false, cancelable: true };
22
23type Direction = "ltr" | "rtl";
24type Orientation = "horizontal" | "vertical";
25
26interface DivProps
27 extends useRender.ComponentProps<"div">,
28 React.ComponentProps<"div"> {}
29
30type RootElement = React.ComponentRef<typeof ActionBar>;
31type ItemElement = React.ComponentRef<typeof ActionBarItem>;
32
33function focusFirst(
34 candidates: React.RefObject<HTMLElement | null>[],
35 preventScroll = false,
36) {
37 const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
38 for (const candidateRef of candidates) {
39 const candidate = candidateRef.current;
40 if (!candidate) continue;
41 if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
42 candidate.focus({ preventScroll });
43 if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
44 }
45}
46
47function wrapArray<T>(array: T[], startIndex: number) {
48 return array.map<T>(
49 (_, index) => array[(startIndex + index) % array.length] as T,
50 );
51}
52
53function getDirectionAwareKey(key: string, dir?: Direction) {
54 if (dir !== "rtl") return key;
55 return key === "ArrowLeft"
56 ? "ArrowRight"
57 : key === "ArrowRight"
58 ? "ArrowLeft"
59 : key;
60}
61
62interface ItemData {
63 id: string;
64 ref: React.RefObject<ItemElement | null>;
65 disabled: boolean;
66}
67
68interface ActionBarContextValue {
69 onOpenChange?: (open: boolean) => void;
70 dir: Direction;
71 orientation: Orientation;
72 loop: boolean;
73}
74
75const ActionBarContext = React.createContext<ActionBarContextValue | null>(
76 null,
77);
78
79function useActionBarContext(consumerName: string) {
80 const context = React.useContext(ActionBarContext);
81 if (!context) {
82// … truncated

What it pulls in

npm packages

  • @base-ui/react

Other registry items

  • button
  • direction
  • @diceui/use-as-ref
  • @diceui/use-isomorphic-layout-effect

Files it writes

  • ui/action-bar.tsx

Facts

Registry
diceui/base
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-09
Last confirmed
yesterday

Go to the source

www.diceui.com sadmann7/diceui on GitHub Raw registry item This item as JSON

More from diceui/base

All 192 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
angle-sliderangle-sliderdiceui/baseComponentsFree1 dep · 3 files
avatar-groupavatar-groupdiceui/baseComponentsFree1 dep
badge-overflowbadge-overflowdiceui/baseComponentsFree1 dep · 2 files
bannerbannerdiceui/baseComponentsFree1 dep
circular-progresscircular-progressdiceui/baseComponentsFree1 dep
client-onlyclient-onlydiceui/baseComponentsFreeno deps
color-pickercolor-pickerdiceui/baseComponentsFree1 dep · 2 files
color-swatchcolor-swatchdiceui/baseComponentsFree1 dep
BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex