aiellie

Search

Find a component, template or page

GitHub
Components

Effort Menu

How hard the model thinks, set from the composer: a button showing the level, opening a slider of six named levels from Off to Max that match the AI SDK's reasoning option.

fig. 01 · open it full screen from the corner

Installation

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

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

Effort Menu sets how hard the model thinks, from the composer. The button shows the level as a few rising bars and its name; it opens a slider of six named levels, Off, Minimal, Low, Medium, High and Max, saying what the chosen one is for. The ids are the AI SDK's own reasoning levels, so the value goes straight to streamText.

Getting started

  1. Put it in the composer

    components/chat-input.tsx
    "use client"
    
    import * as React from "react"
    
    import {
      Composer,
      ComposerFooter,
      ComposerInput,
      ComposerSubmit,
    } from "@/components/aiellie/composer"
    import { EffortMenu } from "@/components/aiellie/effort-menu"
    
    export function ChatInput({ onSend }: { onSend: (text: string, effort: string) => void }) {
      const [effort, setEffort] = React.useState("medium")
    
      return (
        <Composer onSubmit={(text) => onSend(text, effort)}>
          <ComposerInput />
          <ComposerFooter>
            <EffortMenu value={effort} onValueChange={setEffort} className="me-auto" />
            <ComposerSubmit />
          </ComposerFooter>
        </Composer>
      )
    }
  2. Hand it to the model

    Send the level with the request and pass it as reasoning. Providers that can't think at a level ignore it.

    app/api/chat/route.ts
    const { messages, effort } = await request.json()
    
    const result = streamText({
      model,
      messages: await convertToModelMessages(messages),
      reasoning: effort,
    })

Anatomy

<button data-slot="effort-menu"> {/* popover trigger */}
  <span data-slot="effort-bars" />
  Medium
</button>
<div data-slot="effort-menu-content"> {/* popover, in a portal */}
  {/* label and level, the slider, what the level is for */}
</div>

The slider is Base UI's, so arrow keys, Home and End move it, and it reads out the level's name rather than its number. Each stop is a dot on the track.

It opens above the button by default, since it usually sits at the bottom of the page.

Examples

In the composer's footer

Your own levels

options replaces the six. Their ids are whatever your route expects.

<EffortMenu
  options={[
    { id: "fast", name: "Fast", description: "Answers at once." },
    { id: "deep", name: "Deep", description: "Thinks it through first." },
  ]}
  value={effort}
  onValueChange={setEffort}
/>

API reference

EffortMenu

PropTypeDefaultDescription
valuestringrequiredThe chosen level's id.
onValueChange(value: string) => voidrequired
optionsEffortOption[]EFFORT_OPTIONSThe levels, lowest first.
labelstring"Effort"What is being chosen, shown in the panel and read out on the button.
side, align"top", "start"Where the panel opens.
renderReactElementa small ghost ButtonThe button it renders as.

All other popover trigger props are forwarded.

EffortOption

FieldTypeDefaultDescription
idstringrequired
namestringrequired
descriptionstringrequiredWhat the level is for, shown while it's chosen.