组件

Sticker picker

A popover of stickers to choose from: a search field, category chips and a grid you walk with the arrow keys. Reach for it in a comment box, a reaction bar or a profile editor. The highlighted sticker peels its corner.

安装

terminal
npx shadcn@latest add @wobko/sticker-picker

第一次使用?先把 registry 加进 components.json。 如何安装

示例

A sticker for the job

Type to search, click a category, or walk the grid with the arrow keys. The highlighted sticker peels its corner; Enter sticks it.

Your own set

Offer only the stickers you want, under your own names and words. Here a reaction picker: four to a row, it stays open so you can react more than once (choose one again to take it back), and the latest choice is marked.

In a comment box

The picker as a composer tool: choose a sticker, it waits beside the text (click it to take it off), and posting sends both. Recent stickers come first next time.

API 参考

StickerPicker

A Popover (same open, defaultOpen, onOpenChange, modal) that also holds what the grid needs: the catalog, the recent list and what happens on choosing.

属性类型默认值说明
onSelect(sticker: StickerPickerItem) => void-Called with { name, label, category, categoryLabel, tags } when one is chosen (Enter, or a tap).
valuestring | null-The sticker chosen elsewhere: it is marked in the grid (aria-selected, and a check).
stickers(string | { name; label?; category?; tags? })[]-Offer only these, in this order, under your own labels, categories and search words. Names that have not been drawn are skipped. Default: everything in the art library, grouped by the batch it was drawn in.
recentstring[]-Ids to show first under "Recent" (in the unfiltered view). Keep them in your own state.
closeOnSelectbooleantrueClose after choosing. Turn off to add several in a row.

StickerPickerContent

The slip that opens: search field, category chips, the grid, and a caption naming the highlighted sticker. Its body exists only while open, so the search starts fresh every time.

属性类型默认值说明
columnsnumber5Stickers per row (at least 1).
sizenumber44Drawn size of a sticker in the grid, px.
placeholderstring"Search stickers"Placeholder of the search field.
align / side / …PopoverContent props-Everything PopoverContent takes (stock, pin, tape, arrow, sideOffset).

无障碍

  • The search field is a combobox (aria-expanded, aria-controls, aria-autocomplete="list") and keeps focus; the grid is a listbox of options that the field points at with aria-activedescendant, grouped by category (role group, named by its heading).
  • Arrow keys move the highlight: Left and Right one sticker, Up and Down one row (a row is `columns` wide; between categories the column is kept as far as it goes). Home and End go to the first and last while the field is empty. With text in the field, Left and Right move the caret until it reaches the end it is heading for. Enter chooses. Escape closes and returns focus to the trigger.
  • Pressing a sticker with the mouse does not move the focus out of the search field, so with closeOnSelect off the arrow keys keep working between picks.
  • Each option is named by its sticker ("Rocket"); the count of matches is announced politely as you type ("12 stickers.", "No stickers found.").
  • The category chips are toggle buttons (aria-pressed) in their own tab stop; clicking one returns focus to the field. The row scrolls sideways on a narrow popover.
  • The highlighted sticker is shown by a highlighter swipe behind it, a small turn and the peeled corner, not by color alone. Windows high contrast keeps the stickers (intrinsic art).
  • The empty state has a status line and Stubby with a magnifier.

源码

CLI 会复制进你项目的文件。

正在加载源码