--- name: studio-ui-patterns description: Design system UI patterns for Supabase Studio. Use when building or updating pages, forms, tables, charts, empty states, navigation, cards, alerts, dialogs, side panels (sheets), or interactive controls (tooltips, buttons, focus, accessibility). Covers layout selection, Studio primitives, composition, and accessibility parity. --- # Studio 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 than `space-y-*` (fragile under `prose`/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-in `loading` prop 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 `` 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 `
`s | | Dotted tooltip trigger text | `TOOLTIP_UNDERLINE_CLASS_NAME` (`components/ui/tooltip-styles`) | | Technical identifier in copy | Plain `` (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`/`PageSectionAside` for those actions). - If no filters exist, place actions in `PageHeaderAside` or `PageSectionAside`. 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 plain `Table` for simple static display); never add new `react-data-grid` imports. - 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 `` fields need staged-Escape handling (see the `studio-shortcuts` skill). 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 `useChart` context 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 `NavMenu` for 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 `CardContent` for sections and `CardFooter` for actions. Only add `CardHeader`/`CardTitle` when surrounding context doesn't already identify the card (e.g. multiple distinct settings cards). - **Admonition** (`ui-patterns/Admonition`): use `` for short (1–2 sentence) callouts or warnings at the top of a page or section — never as a substitute for `Card`. Consolidate stacked warnings into a single block. - **Global banners**: mount org/app-wide banners in `components/interfaces/App/AppBannerWrapper.tsx`, not `ProjectLayout`. ## 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` (`SheetContent` `size="lg"` for horizontal forms) or `DialogHeader`/`DialogTitle`/`DialogSection`/`DialogFooter` (with a separator between `DialogHeader` and `DialogSection`). - Respect built-in primitive padding and chrome: rely on `DialogSection`/`SheetSection`/header built-in spacing instead of overriding or re-padding inner slots, and use `DialogFooter`/`SheetFooter` only when real actions exist (omit footers that only duplicate built-in dismissal). - **Confirmation modals** (`ui-patterns/Dialogs/ConfirmationModal` and `ui-patterns/Dialogs/TextConfirmModal` for typed-confirmation destructive actions; never `window.confirm`): keep `description` concise (put multi-sentence details in `children`), reserve `variant="destructive"` for actual data loss, and compose `` 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 (`

`–`

` for headings, `