GitHub

Patterns

How SUI components combine for navigation, actions, data entry, data display, overlays, feedback and copy in everyday tasks.

Patterns are the answers SUI gives to recurring tasks. Following them keeps pages consistent with each other, and each one is built from components that already handle keyboard, screen reader, mobile and right-to-left use.

NeedUse
The app's main areasAppShell with a sidebar, or TopNav for a few areas
Sections of one page, such as settingsSectionLayout: a side column on desktop, a row of tabs below it
Views of the same contentTabs
Where the page sits in a hierarchyBreadcrumb, when the hierarchy is deeper than two levels
Jumping anywhere by nameCommand as a palette on ⌘K
  • Mark the current place in exactly one way per level: the active sidebar item, the selected tab.
  • Keep navigation in the same place on every page. Changing pages should not move the menu.
  • Put page actions in the page header (SectionLayout's actions), not in the navigation.

Actions

WeightButton variantUse
PrimarydefaultThe one main action of a view or a dialog
Secondarysecondary, outlineOther actions beside it, such as Cancel
QuietghostToolbar and row actions, icon buttons
DangerdestructiveActions that delete or cannot be undone
InlinelinkNavigation inside text
  • One primary action per view. If two actions seem equal, one of them is secondary.
  • Put the primary action last in a row of buttons (at the end in right-to-left too), with Cancel before it.
  • Show at most three actions in a row; put the rest in a "More" menu.
  • Icon-only buttons are ghost and named by a tooltip.

Data entry

  • Build forms with DataForm, which adds validation, linked fields, steps and overlay forms to Field. Use Field on its own for a few controls without a submit.
  • Every field has a visible label. Placeholders show a format, never the only label.
  • Choose the control by the number of options: a switch or checkbox for on and off, radio buttons for two to five, a select for more, and a select with its search box (SelectSearch) for long lists.
  • Validate when a field loses focus or on submit, not on every keystroke, and show the message under the field in destructive text. Keep what the person typed.
  • Put the primary action at the end of the form; on a page, keep it visible with a sticky footer if the form is long.
  • Disable submit only while a request is in flight, and show progress in the button.

Data display

DataUse
Records to search, filter, sort and act onDataTable
A few records, or records with rich contentItem lists, or DataTable's list and card views
One record's fieldsA description list in a Card, or a Sheet beside the list
Trends and comparisonsCharts
Long text or codeLongText, Code Viewer
  • Align text columns to the start and numbers to the end, with tabular-nums.
  • Show an empty cell as a muted -, not a blank.
  • Keep filters on the toolbar row while they fit; move the rest behind the filter button.
  • Every list has three more states: loading (Skeleton shaped like the content), empty (Empty with the action that fills it) and failed (what happened, and a retry).

Overlays

Pick the overlay by how much of the page the task needs, and keep the page visible behind it whenever you can.

TaskUseWhere it opens
A short decision or a small form that needs focusDialogThe center, sm:max-w-md by default
Confirming something that cannot be undoneAlertDialogThe center; clicking outside does not close it
Viewing or editing one record while keeping the listSheetThe right edge by default (side), sm:max-w-sm
Choices and actions on a phoneDrawer or BottomSheetThe bottom edge, within thumb reach
A quick choice or a few settings beside a controlPopoverNext to its trigger
A list of actionsDropdownMenu, ContextMenuNext to the trigger or the pointer
A preview, or the name of an icon buttonHoverCard, TooltipNext to the element; never holds actions
  • Use a dialog for something people answer and leave; use a sheet for something they read or edit alongside the page. A task that needs more room than a wide sheet gets its own page.
  • Open one overlay at a time. The only overlay that opens over another is the confirmation for an action inside it.
  • Every overlay has a title, closes with Escape and its close button, moves focus inside when it opens and returns it to the trigger when it closes.
  • Keep a dialog's actions in view: long content scrolls inside the body while the header and footer stay put.
  • When an overlay holds unsaved changes, ask before closing it from the backdrop, Escape or a swipe; never discard silently.
  • On phones, prefer a bottom drawer to a centered dialog for choices and short forms. A sheet covers three quarters of a phone screen, leaving the page in view behind it.
  • Keep overlays mounted and control them with open, so they animate in and out instead of appearing and vanishing.

Feedback

SituationUse
An action takes timeA spinner in the button that started it; Skeleton for content
An action finished out of view, or can be undoneToast, with an undo action when possible
Something on the page needs attentionAlert near the content it concerns
A destructive or irreversible actionAlertDialog, or the Delete resource block when typing a name confirms it
Progress through a long taskProgress, or NavigationProgress between pages
  • Confirm only what cannot be undone. Prefer undo over a confirmation for everything else.
  • Name the action in the confirm button ("Delete project"), not "OK", and make it destructive.
  • Don't toast what the page already shows. If the change is visible where the person is looking, it is its own feedback.
  • Errors say what happened and what to do next, next to where it happened.

Copy

  • Write in sentence case: "Save changes", not "Save Changes".
  • Buttons start with a verb and name the result: "Create project", "Export CSV".
  • Use the same word for the same thing everywhere. If it is a "workspace" in the menu, it is a "workspace" in the dialog.
  • Be brief and specific. "Password must be at least 8 characters" beats "Invalid input".
  • Address the reader as "you"; avoid blaming them ("You entered…") and avoid exclamation marks.
  • Give every icon-only control an accessible name, and translate it along with the visible text. Components take their accessible text as props for this (Compatibility).