Prompt Library
Saved prompts with variables that drop straight into the composer. Handles fill-in forms, slash commands, version history and shared, view-only prompts.
- Kategorie
- KI
- Genutzte Komponenten
- 21
- Dateien
- 12
- Anwendungsbeispiele
- 3
- Zugang
- HextaUI Pro (55 Blöcke)
- Quellcode aktualisiert
- Gezählt in
- Studie zur Komponentennutzung
Teil von HextaUI Pro, alle 55 Blöcke, $49 einmalig, Pläne vergleichen
Everyone on a team ends up with the same few prompts in a notes app: write release notes, summarize a PR, draft a support reply. Each time they paste it, they hunt for the parts to change. Prompt Library keeps those prompts next to the chat, marks the parts that change as {{variables}}, and fills them in with a short form before the prompt goes into the composer.
Each variable gets its own color, by its order in the prompt, and keeps it everywhere: the highlight in the editor, the chip in the list, the dot beside its field and the filled-in text in the preview. You can see at a glance which answer goes where. The list stays quiet: each row shows the title, the prompt itself with its variables as chips, who shared it and when it was last used.
The editor highlights variables as you type and suggests them after {{. A name with spaces or symbols gets an inline error with a suggestion, like {{customer_name}}. Each variable is one line that opens to set its name, type (text, long text, options or number), default, hint and whether it can be left empty, and renaming rewrites every place it appears. A live preview fills in sample values, and a prompt can switch the model or override the system prompt.
Search, then press Enter to use the top match. Use opens a form with only the variables the prompt uses, starting at the first one without a default. Enter moves to the next field and submits from the last, and the preview fills in, in each variable’s color, as you type. Type / in Prompt Input to get the same flow from the composer, through Prompt Input’s own menu.
Saving keeps the old text as a version, and History in the editor shows what changed since each one, line by line, with Restore. Duplicate, move, favorite and delete all update at once, and delete offers Undo for five seconds. Import and export use plain JSON. Shared prompts carry their author, and the ones you can’t edit open view only.
HextaUI Pro holen
Eine einmalige Zahlung schaltet jeden Block frei, auch künftige. Preise ansehen.
Die Pro-Registry zu components.json hinzufügen
components.json Token hinzufügen
Erstelle auf deiner Kontoseite einen Token und trage ihn in
.env.localalsHEXTAUI_PRO_TOKENein.Den Block hinzufügen
pnpm dlx shadcn@latest add @hextaui-pro/prompt-library
Store prompts in your database
Pass the prompts and folders you load, and return the saved prompt from onSave. Favorites, moves and deletes update at once and roll back with a message if your API throws. A failed save keeps the editor open with the draft as typed.
Type / in Prompt Input
Put PromptLibraryMenu inside PromptInput and saved prompts join your slash commands in Prompt Input’s own menu. A prompt with variables asks for them first, then lands at the caret, ready to send. Use onUse to switch to the prompt’s model.
A team library with permissions
Mark team prompts shared and set canEdit per prompt. Prompts you can’t edit open view only, with Duplicate to edit instead of Save, and readOnly turns off every change for viewers.
Aufbau
Die Teile, die du zusammensetzt, von außen nach innen.
| Part | Beschreibung |
|---|---|
PromptLibrary | Folders and tags in HextaUI’s Sidebar (a sheet on phones), search, the prompt list, the editor, history, the Use form and import and export. |
PromptLibraryMenu | Adds saved prompts to Prompt Input’s / menu and inserts them filled in. |
UsePromptDialog | The fill-in form on its own, for using a prompt from anywhere. |
PromptPreview | A prompt with values filled in, each in its variable’s color. |
PromptLibrarySkeleton | A loading placeholder shaped like the library. |
usePromptVariables | Reads a prompt’s variables, unknown and invalid names, and returns fill(). |
PromptLibrary
Also accepts every div prop.
| Prop | Typ | Standard |
|---|---|---|
prompts{ id, title, body, variables?, tags?, folder?, model?, system?, favorite?, shared?, canEdit?, author?, updatedAt?, lastUsedAt?, versions? }. | Prompt[] | – |
folders{ id, name, shared? }. Shown in the sidebar and the Move to menu. | PromptFolder[] | – |
onSaveCreate when draft.id is missing, update when it’s set. Also used for duplicates, starters and restores. Throw to keep the editor open with your message. | (draft: PromptDraft) => Promise<Prompt | void> | – |
onDeleteRuns after the undo window. Throw and the prompt comes back. | (prompt) => void | Promise<void> | – |
onUseCalled with the filled-in text. Put it in your composer. | (prompt, { text, values }) => void | – |
onMoveAdds Move to. The card moves at once and goes back if this throws. | (prompt, folder: string | null) => void | Promise<void> | – |
onFavoriteAdds the star. It fills at once and goes back if this throws. | (prompt, favorite: boolean) => void | Promise<void> | – |
onImportSaves an imported file in one call. Without it, each prompt goes through onSave. | (drafts: PromptDraft[]) => void | Promise<void> | – |
readOnlyTurns off creating, editing, moving, deleting and importing. Use and export still work. | boolean | false |
modelsAdds a Model picker to the editor. | { value, label }[] | – |
startersThe three prompts offered when the library is empty. | PromptDraft[] | – |
footerShown under the list, like a composer. Hidden while editing. | ReactNode | – |
undoTimeoutHow long Undo is offered after deleting, in ms. 0 deletes at once. | number | 5000 |
nowFixes the time used for “used 2h ago”, for tests and screenshots. | Date | – |
PromptLibraryMenu
Render inside PromptInput.
| Prop | Typ | Standard |
|---|---|---|
promptsThe prompts to offer after /. | Prompt[] | – |
itemsYour own slash commands, listed before the prompts. | PromptMenuItem[] | – |
onSelectCalled when one of your own commands is picked. | (item) => void | – |
onUseCalled after a prompt is inserted, to record use or switch models. | (prompt, { text, values }) => void | – |
PromptVariable
One entry in a prompt’s variables.
| Prop | Typ | Standard |
|---|---|---|
nameLetters, numbers and _, not starting with a number. | string | – |
typeThe field shown in the Use form. | "text" | "longText" | "select" | "number" | "text" |
defaultUsed when the field is left empty. Options default to the first. | string | – |
optionsThe choices for select. | string[] | – |
descriptionA hint under the field. | string | – |
optionalLets the form submit with the field empty. | boolean | false |
usePromptVariables
Returns { names, variables, unknown, unused, issues, tokens, fill }.
| Prop | Typ | Standard |
|---|---|---|
bodyThe prompt text. | string | – |
definitionsSaved definitions. Names in the body without one count as text. | PromptVariable[] | – |
| Taste | Aktion |
|---|---|
| Enter | In search, uses the top match. The match is highlighted in the list. |
| {{ | In the editor, suggests variables. ↑ and ↓ move, Enter or Tab picks, Escape closes. |
| Enter | In the Use form, moves to the next field, and inserts from the last one. Shift+Enter adds a line in long text. |
| ⌘Enter | In the Use form, inserts from any field. Ctrl+Enter on Windows and Linux. |
| ⌘S | Saves the prompt in the editor. |
| / | In Prompt Input with PromptLibraryMenu, lists saved prompts. |
| Escape | Clears the search. In the editor, a variable’s name goes back to what it was. |
| ⌘B | Shows or hides the folders and tags sidebar. Ctrl+B on Windows and Linux. |
- Each row is a list item whose title is a button that uses the prompt, described by its text, owner and last use. Star and actions sit beside it.
- Variable colors always come with the variable’s name, so nothing depends on color alone, and they turn into underlines in Windows high contrast mode.
- The editor is a combobox while suggesting variables, with the active suggestion announced. Invalid names are listed under the field in a polite live region.
- Each variable row in the editor is a button with aria-expanded that opens its settings. Rows with an error open on their own.
- Saving, using, favoriting, moving, deleting, restoring and importing are announced. Failures show as alerts or toasts with what happened.
- Folders and tags use HextaUI’s Sidebar, with the open filter marked as the current page and counts read out as “3 prompts”. On phones it opens as a sheet. Picking a filter while a draft is unsaved asks before leaving it.
- Text fields are 16px on touch screens so iOS doesn’t zoom, and touch targets grow to 44px. With reduced motion, nothing slides.
Gebaut mit
Die kostenlosen HextaUI-Komponenten, aus denen Prompt Library besteht. Jede lässt sich einzeln installieren.
Code
12 Dateien, hinzugefügt zu components/blocks/prompt-library.