UI Combobox
remocn/comboboxFreeComponent
A combobox whose opened/closed state is a pure function of the timeline; the panel fade/scale/lift are keyframed presets like select. The trigger reuses the Input presets (typed query + caret reveal via an injected inputStyle), the list is filtered by a pure case-insensitive substring on the visible query prefix, and rows reuse the SelectItem row.
Install it
npx shadcn@latest add https://www.remocn.dev/r/combobox.jsonSource
1"use client";23import {4 type InputStyle,5 type InputStyleContext,6 inputStyle,7 inputStyleContext,8} from "@/components/remocn/input";9import {10 SelectItemRow,11 type SelectItemState,12 type SelectItemStyle,13 type SelectItemStyleContext,14 selectItemStyle,15 selectItemStyleContext,16} from "@/components/remocn/select-item";17import {18 type RemocnTheme,19 revealedText,20 useRemocnTheme,21} from "@/lib/remocn-ui";2223export type ComboboxState = "opened" | "closed";2425export interface ComboboxProps {26 state?: ComboboxState;27 style?: ComboboxStyle;28 query?: string;29 revealCount?: number;30 placeholder?: string;31 items?: string[];32 selectedIndex?: number;33 highlightedIndex?: number;34 pressedIndex?: number;35 itemStyles?: (SelectItemStyle | undefined)[];36 inputStyle?: InputStyle;37 theme?: Partial<RemocnTheme>;38 className?: string;39}4041const WIDTH = 280;4243export function filterComboboxItems(44 items: string[],45 query: string,46 revealCount?: number,47): string[] {48 const visible = (49 revealCount === undefined ? query : revealedText(query, revealCount)50 )51 .trim()52 .toLowerCase();53 if (visible === "") return items;54 return items.filter((item) => item.toLowerCase().includes(visible));55}5657export interface ComboboxStyle {58 panelOpacity: number;59 panelScale: number;60 panelTranslateY: number;61}6263export interface ComboboxStyleContext {64 triggerCtx: InputStyleContext;65 panelBg: string;66 panelBorder: string;67 mutedFg: string;68 radius: number;69 itemCtx: SelectItemStyleContext;70}7172export function comboboxStyleContext(theme: RemocnTheme): ComboboxStyleContext {73 return {74 triggerCtx: inputStyleContext(theme),75 panelBg: theme.popover,76 panelBorder: theme.border,77 mutedFg: theme.mutedForeground,78 radius: theme.radius,79 itemCtx: selectItemStyleContext(theme),80 };81}8283export function comboboxStyle(84 state: ComboboxState,85 _ctx: ComboboxStyleContext,86): ComboboxStyle {87 switch (state) {88 case "opened":89 return { panelOpacity: 1, panelScale: 1, panelTranslateY: 0 };90 default:91 return { panelOpacity: 0, panelScale: 0.96, panelTranslateY: -4 };92 }93}9495function rowState(96 i: number,97 selectedIndex: number,98 highlightedIndex: number,99 pressedIndex: number,100): SelectItemState {101 if (i === pressedIndex) return "press";102 if (i === selectedIndex) return "selected";103 if (i === highlightedIndex) return "hover";104 return "idle";105}106107export function Combobox({108 state = "closed",109 style,110 query = "",111// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from remocn
All 282 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| UI Accordionaccordion | remocn | Components | Free | 1 dep · 2 files | |
| UI AI Prompt Flowai-prompt-flow | remocn | Components | Free | 1 dep | |
| UI Alert Dialogalert-dialog | remocn | Components | Free | 1 dep · 2 files | |
| Animated Bar Chartanimated-bar-chart | remocn | Components | Free | 1 dep | |
| Animated Line Chartanimated-line-chart | remocn | Components | Free | 1 dep | |
| ASCII Dissolveascii-dissolve | remocn | Components | Free | 2 deps | |
| ASCII Renderascii-render | remocn | Components | Free | 1 dep | |
| Backdropbackdrop | remocn | Components | Free | 1 dep |
