BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/diceui/radix/selection-toolbar

selection-toolbar

diceui-radix/selection-toolbar
FreeComponent

diceui/radix publishes no description for this item.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/radix-nova/selection-toolbar.json

Source

ui/selection-toolbar.tsxraw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/radix-nova/selection-toolbar.json · first 6 KB
1"use client";
2
3import {
4 autoUpdate,
5 flip,
6 hide,
7 limitShift,
8 type Middleware,
9 offset,
10 type Placement,
11 shift,
12 size,
13 useFloating,
14} from "@floating-ui/react-dom";
15import { Slot as SlotPrimitive } from "radix-ui";
16import * as React from "react";
17import * as ReactDOM from "react-dom";
18import { useComposedRefs } from "@/lib/compose-refs";
19import { cn } from "@/lib/utils";
20import { useAsRef } from "@/registry/bases/radix/hooks/use-as-ref";
21import { useIsomorphicLayoutEffect } from "@/registry/bases/radix/hooks/use-isomorphic-layout-effect";
22import { useLazyRef } from "@/registry/bases/radix/hooks/use-lazy-ref";
23import { Button } from "@/registry/bases/radix/ui/button";
24
25const ROOT_NAME = "SelectionToolbar";
26const ITEM_NAME = "SelectionToolbarItem";
27
28const SIDE_OPTIONS = ["top", "right", "bottom", "left"] as const;
29const ALIGN_OPTIONS = ["start", "center", "end"] as const;
30
31type Side = (typeof SIDE_OPTIONS)[number];
32type Align = (typeof ALIGN_OPTIONS)[number];
33type Boundary = Element | null;
34
35interface DivProps extends React.ComponentProps<"div"> {
36 asChild?: boolean;
37}
38
39type ItemElement = React.ComponentRef<typeof SelectionToolbarItem>;
40
41function getSideAndAlignFromPlacement(placement: Placement) {
42 const [side, align = "center"] = placement.split("-");
43 return [side as Side, align as Align] as const;
44}
45
46function isNotNull<T>(value: T | null): value is T {
47 return value !== null;
48}
49
50interface SelectionRect {
51 top: number;
52 left: number;
53 width: number;
54 height: number;
55}
56
57interface StoreState {
58 open: boolean;
59 selectedText: string;
60 selectionRect: SelectionRect | null;
61}
62
63interface Store {
64 subscribe: (callback: () => void) => () => void;
65 getState: () => StoreState;
66 setState: <K extends keyof StoreState>(key: K, value: StoreState[K]) => void;
67 notify: () => void;
68 batch: (fn: () => void) => void;
69}
70
71const StoreContext = React.createContext<Store | null>(null);
72
73function useStoreContext(consumerName: string) {
74 const context = React.useContext(StoreContext);
75 if (!context) {
76 throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
77 }
78 return context;
79}
80
81function useStore<T>(
82 selector: (state: StoreState) => T,
83 ogStore?: Store | null,
84): T {
85 const contextStore = React.useContext(StoreContext);
86
87 const store = ogStore ?? contextStore;
88
89 if (!store) {
90 throw new Error(`\`useStore\` must be used within \`${ROOT_NAME}\``);
91 }
92
93 const getSnapshot = React.useCallback(
94// … truncated

What it pulls in

npm packages

  • @floating-ui/react-dom
  • radix-ui

Other registry items

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

Files it writes

  • ui/selection-toolbar.tsx
  • lib/compose-refs.ts

Facts

Registry
diceui/radix
Type
registry:ui
Access
Free
Files written
2
Licence
the repository states none
In the index
at or before 2026-08-08
Last confirmed
3 days ago

Go to the source

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

More from diceui/radix

All 58 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
action-baraction-bardiceui/radixComponentsFree1 dep · 2 files
angle-sliderangle-sliderdiceui/radixComponentsFree1 dep · 3 files
avatar-groupavatar-groupdiceui/radixComponentsFree1 dep
badge-overflowbadge-overflowdiceui/radixComponentsFree1 dep · 2 files
bannerbannerdiceui/radixComponentsFree1 dep
checkbox-groupcheckbox-groupdiceui/radixComponentsFree1 dep
circular-progresscircular-progressdiceui/radixComponentsFree1 dep
client-onlyclient-onlydiceui/radixComponentsFreeno deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

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

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex