Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

ComponentPicker

component-picker

Component-library browser with a category tree, fuzzy search, and a detail pane.

Usage

Basic usage

Category tree on the left, search on top, result grid on the right. The catalog is fed in by the consumer; the component never fetches it.

  • All6
    • forms2
      • basic2
    • data-display3
      • collection2
      • placeholder1
    • navigation1
      • action1
6 / 6
Buttonbutton

Button · variants and sizes

formsbasic
Inputinput

Input · prefix and suffix slots

formsbasic
Tabletable

Table · sorting and pinned columns

data-displaycollection
Treetree

Recursive tree · keyboard accessible

data-displaycollection
Emptyempty

Empty state · icon and description

data-displayplaceholder
Commandcommand

Command palette · fuzzy search

navigationactionoverlay
tsx
<ComponentPicker items={items} className="h-[420px]" />

Inject a live preview

The library cannot render an instance for an arbitrary slug, so the preview is injected through renderPreview; a placeholder is shown when it is omitted.

  • All6
    • forms2
      • basic2
    • data-display3
      • collection2
      • placeholder1
    • navigation1
      • action1
6 / 6
Buttonbutton

Button · variants and sizes

formsbasic
Inputinput

Input · prefix and suffix slots

formsbasic
Tabletable

Table · sorting and pinned columns

data-displaycollection
Treetree

Recursive tree · keyboard accessible

data-displaycollection
Emptyempty

Empty state · icon and description

data-displayplaceholder
Commandcommand

Command palette · fuzzy search

navigationactionoverlay
Buttonbutton

Button · variants and sizes

Preview

Props

Name
Type
Default
Description
variant"solid" | "ghost""solid"Visual variant
loadingbooleanfalseLoading state
tsx
<ComponentPicker
  items={items}
  className="h-[420px]"
  defaultActiveSlug="button"
  showPreview
  showExamples={false}
  renderPreview={(item) => (item.slug === "button" ? <Button size="sm">OK</Button> : <Tag>{item.name}</Tag>)}
/>

Parse the catalog from llms-full.txt

Parsing is a pure function called on the consumer side; the component sends no network request and assumes no file exists.

2 / 2
Spinnerspinner

Loading indicator · three sizes

feedbackstatus
Skeletonskeleton

Skeleton · placeholder animation

feedbackstatus
Spinnerspinner

Loading indicator · three sizes

Props

Name
Type
Default
Description
size"sm" | "md""md"Size

Examples

This component has no example code

tsx
import { ComponentPicker, parseComponentCatalog } from "@hulianui/ui";

const items = parseComponentCatalog(await fetch("/llms-full.txt").then((r) => r.text()));

<ComponentPicker items={items} className="h-[320px]" showTree={false} />

Command palette form

Use it when you already know which component you want; a category tree and a props table do not fit into a single command line, so this is only a thin wrapper.

tsx
const [open, setOpen] = useState(false);

<ComponentPickerCommand items={items} open={open} onOpenChange={setOpen} onSelect={(slug) => insert(slug)} />

When to use

Use it when your product needs a component catalog browser: search components, filter by category, read the props table and examples, then hand the chosen slug back. Typical hosts are the component panel of an AI site builder, an internal design-system portal, and the block palette of a low-code editor.

  • For a plain quick-jump palette without a category tree or props table, use Command directly, or the ComponentPickerCommand wrapper exported here.
  • To pick an icon use IconPicker; to pick an emoji use EmojiPicker.
  • For a general list page with a query bar rather than a component catalog, use ProTable.

Three boundaries are deliberate, not unfinished work:

  1. It never fetches. items comes from the consumer. A library component must not assume the runtime has llms-full.txt, and must not issue a network request while rendering. Call the pure parseComponentCatalog(text) in your own layer instead.
  2. It never renders an arbitrary component. There is no slug-to-component registry inside the library, and no string evaluation or iframe. Inject a live preview through renderPreview; without it the preview area shows a placeholder.
  3. It does not pull in fuse.js. The ranker is a pure function in this folder, tuned so that a hit on slug or name outweighs a hit on description. A generic library cannot make that distinction: searching btn would float any component whose description happens to scatter b, t, and n above Button.

Import

ts
import {
  ALL_CATEGORY_KEY,
  ComponentPicker,
  ComponentPickerCommand,
  buildCategoryTree,
  defaultPropsOf,
  fuzzyMatch,
  matchesCategory,
  parseComponentCatalog,
  rankComponents,
  scoreComponent,
} from "@hulianui/ui"

Props

ComponentPickerProps

NameTypeDefaultDescription
items *ComponentPickerItem[]-The catalog. An empty array renders the empty-catalog state, which differs from the no-result state.
filterComponentPickerFilter-Controlled { category?, search? }. Pair it with onFilterChange, otherwise the search box and the tree stop responding.
defaultFilterComponentPickerFilter{}Uncontrolled initial filter.
showTreebooleantrueShows the category tree on the left.
showPreviewbooleanfalseShows the preview area inside the detail pane.
showPropsbooleantrueShows the props table (reuses Table).
showExamplesbooleantrueShows example code (reuses CodeBlock).
activeSlugstring | null-Controlled highlighted item, the one the detail pane describes.
defaultActiveSlugstring | nullnullUncontrolled initial highlighted item.
maxResultsnumber60Maximum number of result cards rendered.
labelsPartial\<ComponentPickerLabels\>-UI copy overrides, whole object or single keys. Omit it and the picker takes its copy from the ConfigProvider locale.
classNamestring-Wrapper class. It must establish a height such as h-[560px]; the internal panes then fill it and scroll independently.

ComponentPickerItem

NameTypeDefaultDescription
slug *string-Unique key, also the first argument of onSelect.
name *string-Display name (the PascalCase export name).
description *string-One-line summary.
category *string-Top-level category (layout / forms / data-display…).
group *string-Second-level group (container / advanced / collection…); pass an empty string when there is none.
tagsstring[]-Extra keywords used by search.
propsComponentPickerProp[]-Rows for the detail pane's props table, each { name, type?, default?, description?, required? }.
examplesComponentPickerExample[]-Example code for the detail pane, each { title?, lang?, code }.

ComponentPickerCommandProps (thin wrapper that puts the catalog inside a Command panel)

NameTypeDefaultDescription
items *ComponentPickerItem[]-Same as above.
open *boolean-Controlled open state.
onOpenChange *(open: boolean) => void-Open-state callback.
onSelect(slug: string) => void-Fires when an entry is chosen.
placeholderstringFrom the localeSearch box placeholder.
emptyMessageReactNodeFrom the localeCopy shown when nothing matches.
maxResultsnumber30Maximum rendered entries (note this differs from the 60 used by ComponentPickerProps).
groupByCategorybooleantrueGroups by category with one heading per group.
shortcutbooleanfalseBuilt-in ⌘K / Ctrl+K toggle.
aria-labelstringFrom the localeAccessible name of the panel.

Events

EventTypeDescription
onSelect(slug: string, props: Record\<string, unknown\>) => voidConfirms a choice. The second argument comes from defaultPropsOf(item) and only carries literal defaults; functions and objects are never guessed.
onFilterChange(filter: ComponentPickerFilter) => voidSearch text or category changed. This is the only outlet once filter is controlled.
onActiveChange(slug: string | null) => voidHighlighted item changed by click, arrow key, or Escape.

Slots

SlotTypeDescription
renderPreview(item: ComponentPickerItem) => ReactNodeInjects the live preview. Without it the preview area shows a placeholder rather than blank space.

Pure functions

FunctionSignatureDescription
parseComponentCatalog(text: string, options?: ParseCatalogOptions) => ComponentPickerItem[]Parses llms-full.txt into items. A missing section only drops that field; it never throws.
buildCategoryTree(items, options?) => ComponentPickerCategoryNode[]Derives the all / category / group tree as plain data with per-level counts.
matchesCategory(item, key?) => booleanWhether an item falls under a category key; undefined and "*" always match.
defaultPropsOf(item) => Record\<string, unknown\>Derives initial props from documented default values.
rankComponents(items, query, options?) => RankedComponent[]Ranks and filters. An empty query keeps the original order.
scoreComponent(item, query) => numberScores one item; multiple terms are combined with AND.
fuzzyMatch(query, text) => FuzzyMatch | nullMatches one string and returns the score plus matched indices.

Example

tsx
// The catalog comes from llms-full.txt: parsing runs in your layer, the component only displays.
const text = await fetch("/llms-full.txt").then((r) => r.text());
const items = parseComponentCatalog(text);

<ComponentPicker
  items={items}
  className="h-[560px]"
  showPreview
  renderPreview={(item) => REGISTRY[item.slug]?.() ?? null}
  onSelect={(slug, props) => insertIntoCanvas(slug, props)}
/>
tsx
// Controlled filter: mirror the search text into the URL query.
const [filter, setFilter] = useState<ComponentPickerFilter>({ category: ALL_CATEGORY_KEY });

<ComponentPicker
  items={items}
  className="h-[560px]"
  filter={filter}
  onFilterChange={(next) => {
    setFilter(next);
    router.replace(`?q=${encodeURIComponent(next.search ?? "")}`);
  }}
/>
tsx
// Palette form, for when the target component is already known.
const [open, setOpen] = useState(false);

<ComponentPickerCommand
  items={items}
  open={open}
  onOpenChange={setOpen}
  shortcut
  onSelect={(slug) => insertIntoCanvas(slug)}
/>

Accessibility

  • The search box is a role="combobox" with aria-controls, aria-autocomplete="list", and aria-activedescendant. The result grid is a role="listbox" and every card is a role="option" with aria-selected. Focus stays in the search box and aria-activedescendant points at the highlighted card, which is the WAI-ARIA combobox pattern; focus is never moved between cards.
  • Keyboard: Down and Up move the highlight and wrap around, starting at the first card going down and the last card going up. Enter confirms. Escape backs out one level at a time, clearing the query first and the highlight second. The highlighted card is scrolled with scrollIntoView({ block: "nearest" }).
  • The category tree runs Tree in expandTrigger="icon" mode, so only the arrow expands a branch and the rest of the row still selects. That is what makes a whole category such as forms selectable.
  • The detail pane is a role="region" with an accessible name, so a screen reader can jump straight into it.

Usage notes

  • A height is mandatory. Without one in className the whole block collapses to content height and every independent scroll area stops working, same as Flow and AdminLayout.
  • A controlled filter needs onFilterChange. Use defaultFilter when you only want an initial value. Passing filter without the callback leaves the search box unwritable and the tree unclickable, which reads as a broken component.
  • renderPreview is the only preview path, not an optional convenience. The library will not turn a slug into an instance for you. Leave showPreview at false if you do not want to supply it.
  • The second argument of onSelect may be {}. defaultPropsOf only accepts literal defaults such as true, false, numbers, and quoted strings. Documented defaults written as () => void, {...}, or an em dash are skipped on purpose; the empty object is honest, not a parse failure.
  • parseComponentCatalog does not read the slug from the document, because it is not there. The function first harvests cross-reference links across the whole text, so [Formula](.../components/math) yields math, and only then falls back to kebab-casing the component name. Those two steps cover all 376 entries of this library; the single exception, QRCode to qrcode, is covered by a built-in override. Pass slugOverrides for the abbreviations in your own docs.
  • maxResults caps rendering, not scoring. Every item is scored before the list is truncated, so entry 61 really is ranked 61st rather than dropped. Raise it to see everything, but 376 cards at once will visibly drop frames.
  • UI copy follows the locale by default. Without labels, every string comes from the ConfigProvider locale and falls back to the built-in Chinese when no provider is present; placeholder and emptyMessage on ComponentPickerCommand work the same way. Priority is prop, then locale, then fallback, so overriding one key leaves the rest tracking the app language.
  • ComponentPickerCommand is not the main form. A command line has no room for a category tree or a props table. Internally it uses filter={() => true} with onQueryChange to take over ordering, because the palette's own filter is a substring match that does not rank.

Playground

  • All6
    • forms2
      • basic2
    • data-display3
      • collection2
      • placeholder1
    • navigation1
      • action1
6 / 6
Buttonbutton

Button · variants and sizes

formsbasic
Inputinput

Input · prefix and suffix slots

formsbasic
Tabletable

Table · sorting and pinned columns

data-displaycollection
Treetree

Recursive tree · keyboard accessible

data-displaycollection
Emptyempty

Empty state · icon and description

data-displayplaceholder
Commandcommand

Command palette · fuzzy search

navigationactionoverlay
Buttonbutton

Button · variants and sizes

Props

Name
Type
Default
Description
variant"solid" | "ghost""solid"Visual variant
loadingbooleanfalseLoading state

Examples

tsx
<Button>OK</Button>
<ComponentPicker items={items} className="h-[420px]" />
PreviousPresenterViewData DisplayNextSankey

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Pure functions
    • Example
    • Accessibility
    • Usage notes
  • Playground