Selection Toolbar (Base UI)
iconiq-ui/b-selection-toolbarFreeComponent
Floating selection toolbar with the same Iconiq API layered over Base UI toolbar primitives, including viewport-aware positioning, keyboard shortcuts, and fluid button motion.
Install it
npx shadcn@latest add https://www.iconiqui.com/r/b-selection-toolbar.jsonSource
1"use client";23import { Toolbar as ToolbarPrimitive } from "@base-ui/react/toolbar";4import * as React from "react";5import { createPortal } from "react-dom";67import {8 getSelectionToolbarButtonClassName,9 getSelectionToolbarShortcutLabel,10 isSelectionToolbarCommandActive,11 type SelectionToolbarItem,12 type SelectionToolbarProps,13 selectionToolbarStyles,14 useSelectionToolbar,15} from "./selectiontoolbar";1617export type {18 SelectionToolbarCommand,19 SelectionToolbarItem,20 SelectionToolbarProps,21} from "./selectiontoolbar";2223type ToolbarButtonProps = {24 active?: boolean;25 children: React.ReactNode;26 className?: string;27 disabled?: boolean;28 label: string;29 onMouseDown: (event: React.MouseEvent<HTMLButtonElement>) => void;30 shortcut?: string;31 tabIndex?: number;32};3334const ToolbarButton = React.forwardRef<HTMLButtonElement, ToolbarButtonProps>(35 function ToolbarButton(36 {37 active = false,38 children,39 className,40 disabled = false,41 label,42 onMouseDown,43 shortcut,44 tabIndex = -1,45 },46 ref47 ) {48 return (49 <ToolbarPrimitive.Button50 aria-keyshortcuts={shortcut}51 aria-label={shortcut ? `${label} (${shortcut})` : label}52 aria-pressed={active}53 className={getSelectionToolbarButtonClassName({ active, className })}54 disabled={disabled}55 onMouseDown={onMouseDown}56 ref={ref}57 tabIndex={tabIndex}58 title={shortcut ? `${label} (${shortcut})` : label}59 type="button"60 >61 <span className={selectionToolbarStyles.toolbarButtonIconClassName}>62 {children}63 </span>64 </ToolbarPrimitive.Button>65 );66 }67);6869ToolbarButton.displayName = "SelectionToolbarButton";7071function renderToolbarItems({72 active,73 buttonRefs,74 disabled,75 focusedIndex,76 handleItemAction,77 items,78}: {79 active: ReturnType<typeof useSelectionToolbar>["active"];80 buttonRefs: ReturnType<typeof useSelectionToolbar>["buttonRefs"];81 disabled: boolean;82 focusedIndex: number;83 handleItemAction: (item: SelectionToolbarItem) => void;84 items: SelectionToolbarItem[];85}) {86 return items.map((item, index) => (87 <ToolbarButton88 active={89 item.command90 ? isSelectionToolbarCommandActive(item.command, active)91 : false92 }93 disabled={disabled || item.disabled}94 key={item.id}95 label={item.label}96 onMouseDown={(event) => {97 event.preventDefault();98 handleItemAction(item);99// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from Iconiq UI
All 119 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | Iconiq UI | Components | Free | 2 deps | |
| AI Inputai-input | Iconiq UI | Components | Free | 3 deps | |
| Alertalert | Iconiq UI | Components | Free | 2 deps | |
| Avataravatar | Iconiq UI | Components | Free | 3 deps | |
| Accordion (Base UI)b-accordion | Iconiq UI | Components | Free | 2 deps | |
| Alert Dialog (Base UI)b-alert-dialog | Iconiq UI | Components | Free | 3 deps | |
| Autocomplete (Base UI)b-autocomplete | Iconiq UI | Components | Free | 3 deps | |
| Avatar (Base UI)b-avatar | Iconiq UI | Components | Free | 2 deps |
