studio-ui-patterns
Các mẫu UI hệ thống thiết kế cho Supabase Studio. Sử dụng khi xây dựng hoặc cập nhật
npx skills add https://github.com/supabase/supabase --skill studio-ui-patternsStudio UI Patterns
The Design System docs and demos are the source of truth. Always check the relevant demo file before composing new UI.
Compose the House Stack
Before writing custom markup or styles, search 'ui', 'ui-patterns', apps/studio/components/ui/, and the Design System demos. Compose existing primitives through their documented props and slots rather than cloning them, wrapping them to override built-in behavior, or fighting their internal padding and chrome with structural CSS overrides.
- Layout geometry: own spacing on the parent container with
flex flex-col gap-y-*rather thanspace-y-*(fragile underprose/margin resets) or ad-hoc margins on child sections. - Class merging: always combine classes with
cn(...)from'ui'(never template-literal concatenation); avoid deep structural selectors and conflicting Tailwind utilities. - Async buttons: use
Button's built-inloadingprop directly, and apply loading + disabled states to slow async actions (downloads, exports, mutations) so double-clicks cannot fire parallel requests.
Studio Component Index
| Need | Use |
|---|---|
| Inline link in copy | InlineLink (components/ui/InlineLink) |
| Dynamic/untyped internal/external URL | DynamicLink (components/ui/DynamicLink); prefer TanStack <Link> directly for known typed internal routes |
| Support link | SupportLink (components/interfaces/Support/SupportLink) |
| External or docs link | DOCS_URL (lib/constants) + target="_blank" rel="noopener noreferrer" (when not using InlineLink) |
| Disabled control needing explanation | ButtonTooltip (components/ui/ButtonTooltip) or DropdownMenuItemTooltip (components/ui/DropdownMenuItemTooltip) |
| Floating button over busy content | FloatingPlate ('ui') |
| Small fixed filter set | FilterPopover (components/ui/FilterPopover) instead of a heavy Command combobox |
| Empty table search-result row | TableRowNoResults (components/ui/TableRowNoResults) |
| Expandable rows or sections | Collapsible ('ui'), never hand-rolled toggle <div>s |
| Dotted tooltip trigger text | TOOLTIP_UNDERLINE_CLASS_NAME (components/ui/tooltip-styles) |
| Technical identifier in copy | Plain <code> (auto-styled by packages/config/inline-code.css; opt out with data-code-style="plain") |
Layout
Docs: apps/design-system/content/docs/ui-patterns/layout.mdx
Build pages with PageContainer, PageBreadcrumbs, PageHeader, PageNav, and PageSection (PageLayout has been removed).
| Content type | size |
|---|---|
| Settings, forms, and focused configuration | "small" (or "default") |
| Lists, tables, and detail pages | "default" |
| Dense horizontal content (logs, editors, wide grid) | "full" |
- If filters/search exist on a list page, align table actions with the filters (don't use
PageHeaderAside/PageSectionAsidefor those actions). - If no filters exist, place actions in
PageHeaderAsideorPageSectionAside.
Demos: page-layout-settings.tsx, page-layout-list.tsx, page-layout-list-simple.tsx, page-layout-detail.tsx (all in apps/design-system/registry/default/example/).
Forms
Docs: apps/design-system/content/docs/ui-patterns/forms.mdx
Use FormItemLayout (not manual FormItem/FormLabel/FormMessage/FormDescription) with FormControl wrapping primitives from 'ui'. For schema, subscriptions, dirty state, reset, and submit mechanics, see the react-hook-form skill.
| Context | Layout | Container |
|---|---|---|
| Page (settings/config) | FormItemLayout layout="flex-row-reverse" | Card (CardContent per field; CardFooter for actions) |
| Side panel — wide | FormItemLayout layout="horizontal" | SheetSection |
Side panel — narrow (size="sm" or below) | FormItemLayout layout="vertical" | SheetSection |
Demos: form-patterns-pagelayout.tsx, form-patterns-sidepanel.tsx.
Tables
Docs: apps/design-system/content/docs/ui-patterns/tables.mdx
| Pattern | Use when |
|---|---|
Table | Simple, static, semantic display |
| Data Table | TanStack-powered (@tanstack/react-table); sorting, filtering, paging |
| Data Grid (legacy) | Existing table-editor grids only (legacy) |
- For interactive or data tables, use
@tanstack/react-table(use plainTablefor simple static display); never add newreact-data-gridimports. - Place search/filters above the table aligned left, and actions above the table aligned right (or in the page actions area if the table is primary content with no filters).
- Search/filter
<Input>fields need staged-Escape handling (see thestudio-shortcutsskill).
Demos: table-demo.tsx, data-table-demo.tsx, data-grid-demo.tsx.
Charts
Docs: apps/design-system/content/docs/ui-patterns/charts.mdx
- Use provided chart building blocks; avoid passing raw Recharts components to
ChartContent. - Use
useChartcontext flags for loading/disabled states and avoid over-abstraction.
Demos (in apps/design-system/registry/default/block/): chart-composed-demo.tsx, chart-composed-basic.tsx, chart-composed-states.tsx, chart-composed-metrics.tsx, chart-composed-actions.tsx, chart-composed-table.tsx.
Empty States
Docs: apps/design-system/content/docs/ui-patterns/empty-states.mdx
| Scenario | Pattern |
|---|---|
| Initial / onboarding | Presentational empty state with value prop + clear next action |
| Data-heavy lists | Informational empty state matching the list/table layout |
| Zero results from search | Keep layout consistent with data state to avoid jarring transitions |
| Missing route | Centered Admonition |
Demos: empty-state-presentational-icon.tsx, empty-state-initial-state-informational.tsx, empty-state-zero-items-table.tsx, data-grid-empty-state.tsx, empty-state-missing-route.tsx.
Navigation
Docs: apps/design-system/content/docs/ui-patterns/navigation.mdx
- Use
NavMenufor a horizontal list of related views within a consistent page layout; activating an item must trigger a URL change (no local-only tab state). - For feature-flagged replacements, verify both states: off preserves existing navigation and destinations; on exposes the replacement (intentionally hidden surfaces are explicit exceptions).
Cards, Alerts & Banners
- Cards: group related information with
CardContentfor sections andCardFooterfor actions. Only addCardHeader/CardTitlewhen surrounding context doesn't already identify the card (e.g. multiple distinct settings cards). - Admonition (
ui-patterns/Admonition): use<Admonition title="...">for short (1–2 sentence) callouts or warnings at the top of a page or section — never as a substitute forCard. Consolidate stacked warnings into a single block. - Global banners: mount org/app-wide banners in
components/interfaces/App/AppBannerWrapper.tsx, notProjectLayout.
Dialogs & Sheets (Side Panels)
Use a Sheet when switching pages would break context (e.g. editing a row from a list).
- Compose with
SheetHeader/SheetTitle/SheetSection/SheetFooter(SheetContentsize="lg"for horizontal forms) orDialogHeader/DialogTitle/DialogSection/DialogFooter(with a separator betweenDialogHeaderandDialogSection). - Respect built-in primitive padding and chrome: rely on
DialogSection/SheetSection/header built-in spacing instead of overriding or re-padding inner slots, and useDialogFooter/SheetFooteronly when real actions exist (omit footers that only duplicate built-in dismissal). - Confirmation modals (
ui-patterns/Dialogs/ConfirmationModalandui-patterns/Dialogs/TextConfirmModalfor typed-confirmation destructive actions; neverwindow.confirm): keepdescriptionconcise (put multi-sentence details inchildren), reservevariant="destructive"for actual data loss, and compose<Dialog>directly for custom multi-action flows rather than adding one-off props. - Reset dialog, sheet, and picker state on close or reopen so previous inputs or rejected selections don't leak.
- Wire dirty form dismissal in sheets/dialogs with
useConfirmOnClose+DiscardChangesConfirmationDialog(Cancel, Escape, and backdrop). Source of truth:apps/design-system/content/docs/ui-patterns/modality.mdx.
Accessibility (Three-Modality Parity)
Every interactive control must work across pointer, keyboard, and screen reader with real semantic elements (<h2>–<h4> for headings, <Button asChild><Link> for navigation, never nested <button>s), visible focus, and zero double announcements. Source of truth: apps/design-system/content/docs/accessibility.mdx (focus-ring, focus-inset, focusableWhenDisabled).
- Icon-only buttons with
<Tooltip>: pairaria-label+<Tooltip>+aria-describedby={undefined}with the exact comment// Tooltip repeats the label; screen readers would read it twice. Use contextual row labels (aria-label={`${item.name} actions`}) instead of generic"More options", and keeparia-labelsynced with dynamic toggle state. <Switch>: give a static descriptivearia-label(e.g."Cron job active status"), never a dynamic verb toggling"Enable X"/"Disable X"— screen readers already announce on/off state.- Tooltips & disabled controls: default
<TooltipContent side="bottom">.<TooltipTrigger asChild>must wrap a focusable interactive element (never a<span>,<div>, or icon). Omit tooltips on enabled buttons with descriptive labels; useButtonTooltip(setsfocusableWhenDisabled) orDropdownMenuItemTooltipfor disabled controls needing explanation. - Focus & dialog parity: pair
group-hover:opacity-100controls inside non-focusablegrouprows withgroup-focus-within:opacity-100and/orfocus-visible:opacity-100(plusdata-[state=open]:opacity-100for menu/popover triggers;group-focus-visible:opacity-100only works when thegroupancestor itself is focusable, such as a<button>or<Link>); restore focus to the trigger button (orDropdownMenuTrigger) when closing state-controlled dialogs; includeDialogTitle/SheetTitleandDialogDescriptionwhen descriptive copy exists (never passaria-describedby={undefined}onDialogContentto silence warnings). - Screen-reader & i18n markup: omit redundant
sr-onlywhen visible text oraria-labelalready conveys it; keepsr-onlyinside arelativeancestor (soposition: absolutedoesn't break scroll containers) and never insidehidden. Addtranslate="no"on monetary/cost values.
Copy
Follow the copywriting skill and apps/design-system/content/docs/copywriting.mdx for all UI text (and grep e2e/studio/ when changing visible copy).