Skip to content

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...UseNot
Pick one of two to five options that people should compare at a glanceRadio GroupA Select. It hides the options behind a press.
Pick one of six to about fifteen optionsSelectA 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 pickerNative SelectA custom Select where the native picker is better for the person.
Pick one or several from a long list, or search by typingComboboxA Select with a scroll of fifty items.
Choose a view mode or a formatting option from a small set, as a group of buttonsToggle GroupRadio buttons. A toggle group acts on the screen at once.
Turn one setting on or off, with an immediate effectSwitchA Checkbox. A checkbox is saved with a form, a switch applies now.
Agree to something, or pick any number of independent options in a formCheckboxA Switch, which implies an immediate effect.
Press once to turn a single tool on or offToggleA Checkbox in a toolbar.
Enter short free textInput, inside a FieldA Textarea for one line.
Enter longer free textTextareaAn Input that scrolls sideways.
Combine an input with a unit, an icon or a buttonInput GroupPositioning an icon over an Input by hand.
Enter a one-time codeInput OTPSix separate Inputs.
Pick a number in a range where the exact value does not matterSliderAn Input, when the person needs the exact number.
Pick a dateCalendar, or Date Picker with its fieldA free-text date.
Do

Show three options as a Radio Group so each one is visible without a press.

Delivery priority
Don’t

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...UseNot
Ask for a decision that blocks work, such as deleting or sendingAlert DialogA 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 fieldsDialogA Sheet for a task that is shorter than its panel.
Show details or a secondary task beside the page, while the page stays in viewSheetA Dialog that covers what the person is referring to.
Show a panel from the bottom edge that the person can swipe away, on a phoneDrawerA 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 itPopoverA Dialog for two controls.
Show a preview of a link or a person on hover, focus or long pressHover CardA Tooltip with a paragraph in it.
Name an icon-only control or explain a shortcut in a few wordsTooltipA Popover, or a label that is visible anyway.
Offer a short list of actions on one objectDropdown MenuA Select. A menu runs actions, a select stores a value.
Offer actions on a right click or long pressContext MenuThe only place a person can find an action.
Search every action and page from the keyboardCommandA 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...UseNot
Say that a field value is wrong and how to fix itAn 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 syncAlertA toast.
Confirm an action that already happened and needs no follow-upToast (Sonner)An Alert that stays on the page forever.
Show that a list or a page has nothing in it, and what to do nextEmptyA blank area or a table with no rows.
Hold the shape of content while it loadsSkeletonA spinner over a blank page.
Show that an action is running and its duration is unknownSpinner, or isPending on a ButtonA progress bar with an invented percentage.
Show how far a measurable job has gotProgressA spinner that never says anything.
Show where one item stands in its flow, such as "Awaiting approval"The state square and a wordA 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 staysA colour with no word.
Warn before an action that cannot be undoneA warning Alert above the control, then an Alert Dialog to confirmA 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 duration when 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.
Do

Put the error next to the field, say what to type, and tie it to the field.

Don’t

Don’t describe a field error in a banner that does not say which field or what to change.

Choose navigation

You need to...UseNot
Move between the main sections of an applicationSidebarTabs. Tabs are for views of one object.
Move between the sections of a website or a docs site, with grouped links that open a panelNavigation MenuA Sidebar on a page with four links.
Switch between related views of the same object without leaving the pageTabsTabs that go to different pages.
Show where the person is in a hierarchy, and offer the way upBreadcrumbA back button as the only way up.
Move through a long list in pagesPaginationInfinite scroll in a table that people compare.
Put application commands in a menu bar, as in a desktop applicationMenubarA Dropdown Menu for the account.
Reveal or hide a section on the same pageAccordion, or Collapsible for oneTabs.
Split a screen the person may resizeResizableA 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...UseNot
Compare values across rows and columnsTableA list of Cards. Cards cannot be scanned in columns.
Sort, filter, select or page through a large set of rowsData TableA Table with hand-written sort buttons.
Show a list of things, each with a title, a description and an actionItemA Table with one column.
Show a self-contained subject with its own heading and actionsCardA Card around every section of the page.
Show a number over time, or a share of a wholeChartA Table for a trend people should see.
Show a person, a company or a siteAvatar, with a name beside itAn avatar alone, which says nothing to a screen reader or a stranger.
Show a file the person attachedAttachmentA 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 momentUseNot
The conversation as a wholeChat, with Message for each turnA custom scroller.
The person writes to the agentPrompt Input, with Model Selector if the person may chooseA bare Textarea with a send button.
The conversation is empty and the person may not know what to askSuggestionA long welcome message.
The agent is thinking or working, and the person wants to see howReasoning or Chain of ThoughtA spinner for a minute.
The agent used a toolToolA paragraph describing the call.
The agent will do something with consequences and needs approvalConfirmationA toast, or doing it and telling afterwards.
The agent proposes steps before it actsPlanA numbered list in a message.
The agent has several pieces of work in progressTask for one, Queue for the listOne long message.
The agent hands part of the work to another agentSubagentHiding the hand-off.
The answer rests on documentsInline Citation in the sentence, Sources under itA claim with no way to check it.
The person may want to go backCheckpointAsking the person to start again.
The agent ran a command or hit an errorTerminal, Stack Trace, Test ResultsPasting raw output into a message.
The agent works on filesFile TreeA flat list of paths.
The person needs to see how much of the context is usedContextA 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

  1. Look in components/ui and components/ai-elements for the component, then in the registry.
  2. If a component almost fits, compose two: a Button inside an InputGroup, a Badge inside an Item.
  3. 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 ofUse
A hex or rgb() colourbg-background, bg-secondary, bg-card, text-foreground, text-muted-foreground, border-border
A pixel radiusrounded-md for controls, rounded-xl for cards
A raw redtext-destructive, or bg-brand for the one accent
A status colour for a step in a flowThe state square, with a word
A raw green, amber or bluetext-success, text-warning, text-info, with a word and an icon
A font namefont-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 basesHereWhy
onClickonPressOne event for mouse, touch, pen and keyboard.
disabledisDisabledThe same on every component, from Button to Tab.
open, onOpenChange on a triggerisOpen, onOpenChange on the dialog or sheetThe state lives on the overlay.
value on a select or tabs itemid on SelectItem, ComboboxItem and TabsTriggerA React Aria collection item is identified by its key.
value and onValueChange on tabsselectedKey or defaultSelectedKey, and onSelectionChangeThe state is a key.
asChildA trigger as the first child, the overlay as the secondDialogTrigger, SheetTrigger and TooltipTrigger take the trigger first.
<a> styled as a buttonLinkButtonIt navigates on the client through the router.
  • Give every item of a dynamic collection a stable id, and a textValue when 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 ref and 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.