Temporary Chat Toggle
An icon button that turns temporary chat on and off. It holds no state, so your app decides what a temporary chat leaves out.
This chat will be saved
Installation
npx shadcn@latest add "@aiellie/temporary-chat-toggle"shadcn needs the @aiellie registry in components.json first. npx aiellie add temporary-chat-toggle adds it on its first run, then installs the same way.
Temporary chat toggle is the button that turns a chat temporary: one that won't be saved to history or used to remember anything. It is a toggle, so it reads as pressed while on, and its tooltip says what pressing it will do next.
Getting started
Hold the state
It is controlled: pass whether the chat is temporary and a setter.
components/chat-header.tsx"use client" import * as React from "react" import { TemporaryChatToggle } from "@/components/aiellie/temporary-chat-toggle" export function ChatHeader() { const [temporary, setTemporary] = React.useState(false) return ( <header className="flex items-center justify-end p-2"> <TemporaryChatToggle pressed={temporary} onPressedChange={setTemporary} /> </header> ) }Send it with the chat
The toggle only holds the choice. Send it with each request so the server knows not to store the chat.
const { sendMessage } = useChat({ transport: new DefaultChatTransport({ body: { temporary } }), })
Anatomy
<button data-slot="temporary-chat-toggle" aria-pressed> {/* a TooltipIconButton */}
<svg /> {/* a dashed chat bubble */}
</button>It is a 28px TooltipIconButton. While pressed it takes the muted fill and its icon the foreground color, and its tooltip switches from tooltip to pressedTooltip, so the label always names the next press.
Examples
Custom labels
Set both tooltips to say what changes in your product's own words.
API reference
TemporaryChatToggle
| Prop | Type | Default | Description |
|---|---|---|---|
pressed | boolean | required | Whether the chat is temporary. |
onPressedChange | (pressed: boolean) => void | required | Called with the new value when pressed. |
tooltip | string | "Temporary chat" | The label while off. |
pressedTooltip | string | "Turn off temporary chat" | The label while on. |
className | string | Merged onto the button. |
All other TooltipIconButton props are forwarded, except onClick and aria-pressed, which it sets itself.