Component usage
Which component to use for which job, and the rules for composing screens from them.
Silkware has 66 components and 21 agent patterns, and most screens need a dozen of them. This page decides which one fits which job. Each table row starts from what you need to do, names the component to use, and names the one people reach for by mistake. Follow the links for the full rules of each component.
Two rules apply before any table. Compose what is in components/ui before you write anything new, and style it only through semantic tokens. Both are covered at the end of the page, under Composition rules.
Choose an input
| You need to... | Use | Not |
|---|---|---|
| Pick one of two to five options that people should compare at a glance | Radio Group | A Select. It hides the options behind a press. |
| Pick one of six to about fifteen options | Select | A Radio Group. It pushes the form down the page. |
| Pick one of a few options on a phone or in a simple form, with the platform's own picker | Native Select | A custom Select where the native picker is better for the person. |
| Pick one or several from a long list, or search by typing | Combobox | A Select with a scroll of fifty items. |
| Choose a view mode or a formatting option from a small set, as a group of buttons | Toggle Group | Radio buttons. A toggle group acts on the screen at once. |
| Turn one setting on or off, with an immediate effect | Switch | A Checkbox. A checkbox is saved with a form, a switch applies now. |
| Agree to something, or pick any number of independent options in a form | Checkbox | A Switch, which implies an immediate effect. |
| Press once to turn a single tool on or off | Toggle | A Checkbox in a toolbar. |
| Enter short free text | Input, inside a Field | A Textarea for one line. |
| Enter longer free text | Textarea | An Input that scrolls sideways. |
| Combine an input with a unit, an icon or a button | Input Group | Positioning an icon over an Input by hand. |
| Enter a one-time code | Input OTP | Six separate Inputs. |
| Pick a number in a range where the exact value does not matter | Slider | An Input, when the person needs the exact number. |
| Pick a date | Calendar, or Date Picker with its field | A free-text date. |
Show three options as a Radio Group so each one is visible without a press.
Don’t hide three options behind a Select. The person needs two presses to read what one glance would show.
Every input sits in a Field with a visible Label. Use a placeholder only as an example of the format, never as the label.
Choose an overlay
| You need to... | Use | Not |
|---|---|---|
| Ask for a decision that blocks work, such as deleting or sending | Alert Dialog | A Dialog. An alert dialog is built for interruption and does not close on an outside press by default. |
| Run a short task that needs the person's full attention, such as a form with a few fields | Dialog | A Sheet for a task that is shorter than its panel. |
| Show details or a secondary task beside the page, while the page stays in view | Sheet | A Dialog that covers what the person is referring to. |
| Show a panel from the bottom edge that the person can swipe away, on a phone | Drawer | A Sheet with a bottom side, when you want swipe gestures. |
| Show a small set of controls or a short explanation next to the thing that opened it | Popover | A Dialog for two controls. |
| Show a preview of a link or a person on hover, focus or long press | Hover Card | A Tooltip with a paragraph in it. |
| Name an icon-only control or explain a shortcut in a few words | Tooltip | A Popover, or a label that is visible anyway. |
| Offer a short list of actions on one object | Dropdown Menu | A Select. A menu runs actions, a select stores a value. |
| Offer actions on a right click or long press | Context Menu | The only place a person can find an action. |
| Search every action and page from the keyboard | Command | A Combobox. |
- A tooltip never holds something a person must read or do. React Aria documents that tooltips are not shown on touch screen interactions, so anything inside one is invisible on a phone.
- Never open an overlay from an overlay of the same kind. A dialog that opens a dialog is a task that should be a page or a step.
- Give every overlay a title. Dialog, Alert Dialog and Sheet each have a title part; use it and keep it short.
Choose feedback
| You need to... | Use | Not |
|---|---|---|
| Say that a field value is wrong and how to fix it | An inline error with Field (FieldError) | A toast, which disappears before the person can fix the field. |
| Say something that stays true while the person works on the page, such as a failed sync | Alert | A toast. |
| Confirm an action that already happened and needs no follow-up | Toast (Sonner) | An Alert that stays on the page forever. |
| Show that a list or a page has nothing in it, and what to do next | Empty | A blank area or a table with no rows. |
| Hold the shape of content while it loads | Skeleton | A spinner over a blank page. |
| Show that an action is running and its duration is unknown | Spinner, or isPending on a Button | A progress bar with an invented percentage. |
| Show how far a measurable job has got | Progress | A spinner that never says anything. |
| Show where one item stands in its flow, such as "Awaiting approval" | The state square and a word | A coloured badge for every step. |
| Show how a check or an event turned out, such as "Passed" or "Saved" | A success, warning or info Badge with an icon and a word, or the same variant of Alert for a message that stays | A colour with no word. |
| Warn before an action that cannot be undone | A warning Alert above the control, then an Alert Dialog to confirm | A toast, or a warning colour on the button. |
- A toast is for confirmation only. It disappears by itself, so it never carries the only copy of an error, a number or a next step. The Silkware Toaster defaults to 4000 milliseconds, and React Aria's own guidance for accessible toasts is a minimum of five seconds, so set
durationwhen the message has a sentence in it. - A message that needs a decision is a dialog. A message that needs no decision and should stay is an alert. A message that confirms is a toast.
- One feedback per event. An error in a field is shown in the field; do not also add an alert at the top and a toast.
Put the error next to the field, say what to type, and tie it to the field.
Don’t describe a field error in a banner that does not say which field or what to change.
Choose navigation
| You need to... | Use | Not |
|---|---|---|
| Move between the main sections of an application | Sidebar | Tabs. Tabs are for views of one object. |
| Move between the sections of a website or a docs site, with grouped links that open a panel | Navigation Menu | A Sidebar on a page with four links. |
| Switch between related views of the same object without leaving the page | Tabs | Tabs that go to different pages. |
| Show where the person is in a hierarchy, and offer the way up | Breadcrumb | A back button as the only way up. |
| Move through a long list in pages | Pagination | Infinite scroll in a table that people compare. |
| Put application commands in a menu bar, as in a desktop application | Menubar | A Dropdown Menu for the account. |
| Reveal or hide a section on the same page | Accordion, or Collapsible for one | Tabs. |
| Split a screen the person may resize | Resizable | A fixed split that cannot give way on a phone. |
See the navigation pattern for how these fit together.
Choose a data display
| You need to... | Use | Not |
|---|---|---|
| Compare values across rows and columns | Table | A list of Cards. Cards cannot be scanned in columns. |
| Sort, filter, select or page through a large set of rows | Data Table | A Table with hand-written sort buttons. |
| Show a list of things, each with a title, a description and an action | Item | A Table with one column. |
| Show a self-contained subject with its own heading and actions | Card | A Card around every section of the page. |
| Show a number over time, or a share of a whole | Chart | A Table for a trend people should see. |
| Show a person, a company or a site | Avatar, with a name beside it | An avatar alone, which says nothing to a screen reader or a stranger. |
| Show a file the person attached | Attachment | A plain link. |
- Use a card when the content is one subject that could stand on its own: one order, one supplier. Do not use a card to give a section a border; use a tone step as in Information hierarchy.
- Never put a card in a card. If a card holds rows, those are Items, not cards.
Choose an agent pattern
Agent interfaces are built from the AI Elements. Pick the pattern from the moment in the conversation.
| The moment | Use | Not |
|---|---|---|
| The conversation as a whole | Chat, with Message for each turn | A custom scroller. |
| The person writes to the agent | Prompt Input, with Model Selector if the person may choose | A bare Textarea with a send button. |
| The conversation is empty and the person may not know what to ask | Suggestion | A long welcome message. |
| The agent is thinking or working, and the person wants to see how | Reasoning or Chain of Thought | A spinner for a minute. |
| The agent used a tool | Tool | A paragraph describing the call. |
| The agent will do something with consequences and needs approval | Confirmation | A toast, or doing it and telling afterwards. |
| The agent proposes steps before it acts | Plan | A numbered list in a message. |
| The agent has several pieces of work in progress | Task for one, Queue for the list | One long message. |
| The agent hands part of the work to another agent | Subagent | Hiding the hand-off. |
| The answer rests on documents | Inline Citation in the sentence, Sources under it | A claim with no way to check it. |
| The person may want to go back | Checkpoint | Asking the person to start again. |
| The agent ran a command or hit an error | Terminal, Stack Trace, Test Results | Pasting raw output into a message. |
| The agent works on files | File Tree | A flat list of paths. |
| The person needs to see how much of the context is used | Context | A silent failure when the limit is reached. |
Whatever the pattern, the screen must show what the agent did, and what waits on a person. See UX writing.
Composition rules
Compose before you write
- Look in
components/uiandcomponents/ai-elementsfor the component, then in the registry. - If a component almost fits, compose two: a
Buttoninside anInputGroup, aBadgeinside anItem. - If nothing fits, write a new component that is built from the existing ones and carries no brand values of its own.
Do not edit a file in components/ui to restyle it for one screen. Pass a className for layout (width, margin, alignment) and keep colour, radius and type in the tokens.
Semantic tokens only
A colour, a radius, a font, a shadow and an icon stroke are tokens. A hex value, a font name or a pixel radius inside a component file is a defect, because a rebrand edits app/globals.css alone.
- <div className="rounded-[10px] bg-[#f5f5f7] text-[#6e6e73]">+ <div className="rounded-xl bg-secondary text-muted-foreground">| Instead of | Use |
|---|---|
A hex or rgb() colour | bg-background, bg-secondary, bg-card, text-foreground, text-muted-foreground, border-border |
| A pixel radius | rounded-md for controls, rounded-xl for cards |
| A raw red | text-destructive, or bg-brand for the one accent |
| A status colour for a step in a flow | The state square, with a word |
| A raw green, amber or blue | text-success, text-warning, text-info, with a word and an icon |
| A font name | font-sans or font-heading, and a standard step such as text-xl or text-sm |
React Aria conventions
Silkware is on the React Aria base, and its props differ from other shadcn bases. Code written for the Radix or Base UI versions of shadcn will not work unchanged.
| Other bases | Here | Why |
|---|---|---|
onClick | onPress | One event for mouse, touch, pen and keyboard. |
disabled | isDisabled | The same on every component, from Button to Tab. |
open, onOpenChange on a trigger | isOpen, onOpenChange on the dialog or sheet | The state lives on the overlay. |
value on a select or tabs item | id on SelectItem, ComboboxItem and TabsTrigger | A React Aria collection item is identified by its key. |
value and onValueChange on tabs | selectedKey or defaultSelectedKey, and onSelectionChange | The state is a key. |
asChild | A trigger as the first child, the overlay as the second | DialogTrigger, SheetTrigger and TooltipTrigger take the trigger first. |
<a> styled as a button | LinkButton | It navigates on the client through the router. |
- Give every item of a dynamic collection a stable
id, and atextValuewhen the children are not plain text, so typeahead and screen readers have text to use. - A trigger must be a React Aria component or accept a
refand spread its props to a DOM element, so that the overlay can find it. - Read the component's page before you guess a prop name: the API reference lists each one.