Loading component…
Loading component…
Saved prompt templates with variables – type straight into the sentence, watch the finished prompt assemble below, and use it once every variable is filled
To reuse this local React demo, copy all files from the Code tab into the same folder, then import PromptLibrary from ./prompt-library.
import { PromptLibrary } from "@/components/ui/prompt-library";
export function Prompts() {
return (
<PromptLibrary
templates={[
{
id: "meeting",
title: "Summarize a meeting",
category: "Notes",
body: "Summarize the meeting below for {audience} in under {length}.",
variables: { length: { default: "150 words" } },
},
{
id: "error",
title: "Explain an error",
category: "Debug",
body: "Explain this {language} error in plain words: {error}.",
},
]}
onUse={(prompt) => send(prompt)}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| templates | PromptTemplate[] | { id, title, category?, tone?, body, variables? } – body holds the variables in curly braces, e.g. {audience}; variables maps a name to { description?, default? } | |
| value | string | Id of the chosen template (controlled) | |
| defaultValue | string | Id chosen at first when uncontrolled – the first template by default | |
| onSelect | (id: string) => void | Called when another template is chosen | |
| onUse | (prompt: string, template: PromptTemplate, values: Record<string, string>) => void | Called with the finished prompt when Use is pressed – only possible once every variable is filled | |
| onCopy | (prompt: string) => void | Called after the prompt was copied to the clipboard | |
| title | string | "Prompts" | Heading above the list |
| useLabel | string | "Use prompt" | Label of the use button |
| className | string | Extra class on the root |
Fills its container up to 640px. Below 540px the list moves on top of the template; below 360px Copy keeps only its icon
Fields grow with what you type and never get wider than the line
Touch screens: taller list rows, fields and buttons
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"