shadcn.io is not affiliated with official shadcn/ui
Icon Picker Command Menu Block for React
A page builder's icon picker as a command menu shown open over a block's settings: forty icons drawn at the chosen size and stroke, two sliders that restyle every row, and Enter copies the JSX.
Installation
Overview
Find an icon and copy it ready to paste with this icon picker command menu for React with Base UI. It opens from the Icon field of Pictoryard, a page builder, whose header holds an outline field with its ⌘ K cap, and a block's settings are drawn under a soft scrim inside a hairline frame with a plus mark on each corner. The menu is the catalog Command: forty Lucide icons in six groups, each row the icon drawn at the chosen size and stroke, its name and the import line that brings it in. A band under the list holds two Sliders, Stroke from 1 to 3 and Size from 16 to 32, that restyle every row at once without moving the list, and shows the JSX Enter will copy for the highlighted icon, such as <StarIcon strokeWidth={1.5} size={24} />. Enter copies that JSX through the clipboard, sets the block's icon and closes the menu; the band's Copy button copies without choosing. For preview the menu is drawn open in place when the page loads; the field, or Ctrl or ⌘ K while focus is in the block, opens the real command dialog with the same icons, sliders and query. For page builders, design tools and any product with an icon field.
FAQ
Why is the menu already open, and what do I keep?
So you can see it without a click. On load the menu is the Command with its band drawn inline under a picture of the settings, in a plain shell that is not modal, so nothing is trapped, hidden or focused and the page around the preview keeps working. The header's field opens the real command dialog, modal, with its focus trap, Escape and focus return, and the inline copy stays closed until a reload. Both show the same Palette and share the block's state, so the stroke and size you set in the copy are the ones the dialog opens with. In your app keep the dialog and drop the copy: the "in-place" state, the scrim with its shell and the Escape and blur effects.
How do the sliders work, and why does the list not move?
Each slider steps through five stops (stroke 1, 1.5, 2, 2.5 and 3; size 16, 20, 24, 28 and 32 pixels), so its value is the stop's place and its spoken value is the stop in words ("1.5 stroke", "24 pixels"). Every row keeps a box of the same size for its icon and draws the icon at the chosen size inside it, so a larger icon never makes a taller row and the highlight stays where it was. The sliders sit outside the command, because its keys would take the arrows from them; Tab reaches them from the list.
What does Enter copy, and what changes?
The JSX for the highlighted icon with the props the sliders chose, through the clipboard: the component's name, strokeWidth and size. The status line says what was copied, or that the browser refused. Enter then sets the block's icon (the tile and the Icon field in the drawn settings) and closes the menu with focus on the field. The Copy button in the band copies the same text and changes nothing else. Each row also shows the import line, so what you paste has its import beside it.
Can I use another icon set?
Yes. The set is typed data: a name, the component, a group and the words the search reads, so swap GLYPHS for your own list and change the import line and the JSX in importOf and jsxOf. The rows only draw the component with a size and a strokeWidth, which most icon packages accept; a set with fixed strokes would drop the Stroke slider.
What stays local, and how do I wire it?
All of it. The icons, the sliders and the chosen icon are state in the block; nothing is saved, and the clipboard is the only thing the browser really does. In your app write the chosen icon, size and stroke to the selected block in pick, and persist them with the block.
Is it accessible from the keyboard?
Yes. Type to search by name or by a word like mail or arrow, the arrow keys move through the icons, Enter copies and chooses, and Escape closes the menu and puts focus on the field; Tab reaches the two sliders and Copy. Ctrl or ⌘ K opens the dialog while focus is inside the block, and only then. The rows are options of a cmdk listbox; the block turns off its own fuzzy filter and lists the rows itself. The icons are hidden from assistive technology; every row carries the name, and the block's icon is read as ", the block's icon".
Related
- Pro
Tone Picker Command Menu
Visual pickersA design tool's tone picker as a command menu shown open over its Fill row: an eleven-step grey ramp and recent tones, a HEX, RGB or HSL switch that rewrites every value and what Enter copies, and a band with the highlighted tone's contrast on white and on black.
- AaAgAaAaAaPro
Font Picker Command Menu
Visual pickersA document editor's font menu hung from the toolbar's font name, with six system font stacks each set in its own real CSS stack, a specimen band that follows the highlight, a row of weights and an italic toggle, and Enter to set the document's font.
- Pro
Design Tokens Command Menu
Visual pickersA design-system inspector's token picker as a command menu hung from a Fill field: tokens in groups with their resolved values and a small drawing, a box pane that wears whatever you apply, the alias chain of the last token, and a copy as CSS variable or JSON.
- Pro
New Page Template Command Menu
Edit and insertA site builder's new-page menu shown open over its page tree: templates in five groups each with a drawn wireframe of six lines, a typed name that turns the list into Create from templates, and choosing one adds the page, with its slug, to the tree and selects it.
- Pro
Emoji Picker Command Menu
Visual pickersA team chat's emoji menu shown open over its composer: names and shortcodes, a skin-tone switch for hands and people, and Enter adds an emoji to the message under the list while the menu stays open.
- Pro
Basic Command Menu
Search everythingA team workspace's home page with its command menu shown open: eleven pages in three groups, a shortcut on the five most used, matches marked, an empty state that says what to try and a foot with the key hints and a spoken count.