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.

Attachment

A file as a compact chip: its name, kind and size, upload progress, and Remove or open.

When to use it: For files on a prompt and in a sent message. A form that collects documents uses FileUpload.

Apps, websites and embeds

Example

  • meeting-notes-24-nov.docx Uploading 0%
    Uploading meeting-notes-24-nov.docx

  • q4-budget.xlsx XLSX, 412 kB
  • site-walkthrough.mov Too large to send. Files up to 20 MB.

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
  • Give every status and meaning a word, an icon or a pattern as well as colour. colour.not-alone

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

A file as a compact chip, in a prompt or a sent message: a thumbnail for an image (preview), else the file's icon; the name on one line and its kind and size ("PDF · 2.4 MB", the kit's number format); while uploading, "Uploading 40%" and a bar along its foot; on failure the error in words, the chip's edge in the danger tone. onRemove shows Remove named for the file; href (a link) or onOpen (a button) opens it, named by the file's name and described by its kind and size. AttachmentList is the row of them PromptBox and Message use: items (FileUpload's file shape plus type, kind, preview and href), label, onRemove(id) or onOpen(id); it says once each that a file was removed, uploaded or failed, and after a remove moves focus to the next Remove. Every string is a prop.

Styles: css/attachment.css.

How it’s built

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

Lifting state up

The app owns the files and their upload state; the list reports removes and opens and renders what it is given.

Partial rendering

A thumbnail only with a preview, Remove only with onRemove, a link or a button only when the file opens, the bar only while uploading.

Deriving state

The kind comes from the name's extension or the type, and the words from the status, during render.