aiellie

Search

Find a component, template or page

GitHub
Components

Prompt Menu

A menu of preset instructions to put the assistant under, grouped, with a line on how each changes the answer.

fig. 01 · open it full screen from the corner

Installation

npx shadcn@latest add "@aiellie/prompt-menu"

shadcn needs the @aiellie registry in components.json first. npx aiellie add prompt-menu adds it on its first run, then installs the same way.

Prompt Menu picks the preset instructions the assistant answers under, like Concise or Code reviewer, from beside the composer. Each prompt says under its name how it changes the answer, and they're grouped under headings.

None is the first row, because answering with no preset is the usual case. The button shows the chosen prompt's name, and darkens while one is set.

Getting started

  1. Keep the choice

    components/composer-prompt.tsx
    "use client"
    
    import * as React from "react"
    
    import { PromptMenu } from "@/components/aiellie/prompt-menu"
    
    export function ComposerPrompt() {
      const [prompt, setPrompt] = React.useState("")
      return <PromptMenu value={prompt} onValueChange={setPrompt} />
    }
  2. Send the instructions

    Each prompt carries its text in prompt. Add it to the system message in your route.

    lib/system.ts
    import { PROMPTS } from "@/components/aiellie/prompt-menu"
    
    export function systemFor(id: string) {
      return PROMPTS.find((prompt) => prompt.id === id)?.prompt
    }

Anatomy

<button data-slot="prompt-menu" data-active /> {/* menu trigger */}
<div data-slot="menu-content"> {/* in a portal */}
  <div data-slot="menu-radio-group">
    {/* None */}
    {/* per group: a rule, a heading, then a row per prompt */}
  </div>
</div>

It's the aiellie Menu with radio rows, so one prompt is chosen at a time, and the menu closes when you pick one. A long list scrolls inside the menu.

Examples

Your own prompts

prompts and groups replace the presets, which are sample data to start from.

API reference

PromptMenu

PropTypeDefaultDescription
valuestringrequiredThe chosen prompt's id, or "" for none.
onValueChange(value: string) => voidrequired
promptsPrompt[]PROMPTS
groupsPromptGroup[]PROMPT_GROUPSThe headings, in order.
labelstring"Prompt"Shown while no prompt is chosen.
side, alignWhere the menu opens.
renderReactElementa small ghost ButtonThe button it renders as.

All other menu trigger props are forwarded.

Prompt

FieldTypeDefaultDescription
idstringrequired
namestringrequired
groupstringrequiredThe id of the group it goes under.
descriptionstringrequiredHow the answer changes.
promptstringrequiredThe instructions to send.
iconIconSvgElementrequiredA Hugeicons glyph.

A PromptGroup is { id, name, icon }.