Skip to content
Get started

Search the docs

Quick start
Installation
Build your first page
What is public
Thinking in Turtlekit
Apps, websites and embeds
Components or native elements
Colour
Typography
Layout
Spacing, icons and shape
Components
Root
Layout
Typography
Code block
Button
Icon button
Button group
Call to action
Toolbar
Field
Text field
Text area
Select
Combobox
Date input
Save bar
Newsletter signup
Prompt box
File upload
Calendar
One-time code
Checkbox
Radio group
Switch
Segmented control
Toggle
Slider
Attachment
Response
Badge
Card
Data list
Item
Icon tile
Num
Time
Metric
Accordion
FAQ
Avatar
Media
Scroll area
Resizable
Carousel
Image slider
Logo cloud
Testimonials
Steps
Conversation
Message
Table
Data table
Chart
Site header
Site footer
Tabs
Page header
Breadcrumb
Pagination
Sidebar
Navigation menu
Callout
Error summary
Toast
Empty state
Skeleton
Progress
Spinner
Tooltip
Dialog
Popover
Hover card
Dropdown menu
Context menu
Menubar
Command
Elements area
Visually hidden
Error boundary
Design rules
Staying within the kit
Layout
Icons
Images and media
Typography
Readability
Colour
Composition
Accessibility
Elements
Motion
Interaction
AI pitfalls
Pricing
React design patterns
Single responsibility in React components
Presentational and container components in React
Children, function children and render props in React
The variant pattern in React
Compound components in React
Higher-order components in React
State colocation in React
Lifting state up in React
Deriving state during render
One status instead of many booleans
Adjusting state when a prop changes
Reading context with use() in React 19
Context selectors in React
Custom hooks and hook composition in React
One effect per concern in React
The latest ref pattern in React
Effect Events with useEffectEvent in React
Detecting the first render in React
Exposing methods with useImperativeHandle in React
Debouncing input in React
useDeferredValue in React
Loading components on demand in React
Virtualising long lists in React
Guard clauses and early returns in React
Skeleton placeholders in React
Rendering partial data in React
Empty states in React
Error boundaries in React
Reading async data with use() and Suspense in React
useTransition and Actions in React
Optimistic UI updates with useOptimistic
useActionState and form Actions in React
useSyncExternalStore in React
Ref as a prop and ref cleanup in React 19
Accessible ids with useId in React
Portals in React
Roving focus and keyboard navigation in React
Controlled and uncontrolled components in React
The state reducer and prop getters in React
Headless components and the provider pattern in React
The polymorphic as prop in React

Appearance

These change every page and preview on this site.

Prompt box

PromptBox

Where a person writes to an AI agent: a growing field, Send that turns to Stop, and attached files.

When to use it: At the foot of a chat or an assistant panel. Enter sends; Shift+Enter starts a new line.

Apps, websites and embeds

Example

  • brightwater-contract-2026.pdf PDF, 412 kB
  • site-visit.jpg Uploading 64%
    Uploading site-visit.jpg

Enter sends. Shift+Enter starts a new line.
Enter sends. Shift+Enter starts a new line.

You're offline. You can send once you're back online.

Enter sends. Shift+Enter starts a new line.

Guidelines

  • Give every button, link and icon button a name, every image alt text (alt="" for decoration), and every SVG aria-hidden or role="img" with a name. a11y.accessible-name
  • Reach a custom control (role="button", "tab", "checkbox" and the like) with Tab and work it with Enter and Space, or use the native element or the kit component. a11y.keyboard
  • Label buttons with a verb and an object ("Save settings", "Delete 3 projects"). composition.button-labels

Add it to your project

It’s included in turtlekit.css and the turtlekit package: install it.

Your AI will also copy only this component, and what it needs, into your project. That comes with Turtlekit Pro, opening soon. Hear when it opens.

In detail

Where a person writes to an AI agent: a field that grows with the message (rows, default 1, to maxRows, default 10, then scrolls), Send at its end and Stop in the same place while a reply streams (streaming, onStop), and a lower row for attach and the app's actions (a mode or model picker, a tool toggle). Enter sends the trimmed message to onSubmit and clears the draft, Shift+Enter starts a new line, an Enter that picks a word being composed (Japanese, Chinese, Korean input) never sends, and on a touch screen Enter starts a line and Send sends; focus stays in the field after sending and after Stop. label names the field for screen readers and is the placeholder unless placeholder is given. Files: with onAttach the box shows an attach button and takes pasted files (a copy from a document stays text) and files dropped on it; files outside accept or over maxSize are refused with the reason; attachments (FileUpload's items: name, size, status, progress, error) show as chips above the field with Remove (onRemoveAttachment), and Send waits while one uploads. maxLength counts near the limit and past it, and Send waits; unavailable says why nothing can be sent now under the box (offline) while people can still write; error says what went wrong, announced, and the message that failed returns to the empty field. Controlled (value, onValueChange) or not (defaultValue); the ref is the textarea. Every string is a prop (sendLabel, stopLabel "Stop the reply", attachLabel, keyHint, dropLabel, attachmentsLabel, removeLabel, rejectLabel, failedLabel, progressLabel, addedLabel, removedLabel, uploadingLabel, formatCount, formatRemaining). Never inside another form: it is one.

Styles: css/prompt-box.css, css/field.css, css/button.css, css/feedback.css.

How it’s built

The engineering patterns inside PromptBox, each explained in Turtlekit Editorial.

Controlled and uncontrolled components

The draft is value with onValueChange, or kept inside from defaultValue, through useControllableState.

Lifting state up

The app owns the attachments and their upload state, and the reply's streaming; the box reports files added and removed, sends and stops, and renders what it is given.

Deriving state

Whether it can send, the count near the limit and the waiting for uploads are derived from the draft, the attachments and the props during render.

Effect separation

Moving focus to the field when a reply ends under a focused Stop, and measuring the field where the browser cannot size it to its content, live in effects.