The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: unify SkipToContent across studio, docs, www, and design-system (#48314)
Danny White37dded67d123
diff --git a/apps/design-system/__registry__/default/block/chart-bar-interactive.tsx b/apps/design-system/__registry__/default/block/chart-bar-interactive.tsxindex fca68de5bc7..128664bb431 100644--- a/apps/design-system/__registry__/default/block/chart-bar-interactive.tsx+++ b/apps/design-system/__registry__/default/block/chart-bar-interactive.tsx@@ -146,7 +146,8 @@ export default function Component() {{['desktop', 'mobile'].map((key) => {const chart = key as keyof typeof chartConfigreturn (- <button tabIndex={0}+ <button+ tabIndex={0}key={chart}data-active={activeChart === chart}className="relative z-30 flex flex-1 flex-col justify-center gap-1 border-t px-6 py-4 text-left even:border-l data-[active=true]:bg-surface-100 sm:border-l sm:border-t-0 sm:px-8 sm:py-6"diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsxindex 3dbe1fb2acf..fade8897fb5 100644--- a/apps/design-system/__registry__/index.tsx+++ b/apps/design-system/__registry__/index.tsx@@ -2502,6 +2502,17 @@ export const Index: Record<string, any> = {subcategory: "undefined",chunks: []},+ "skip-to-content-demo": {+ name: "skip-to-content-demo",+ type: "components:example",+ registryDependencies: undefined,+ component: React.lazy(() => import("@/registry/default/example/skip-to-content-demo")),+ source: "",+ files: ["registry/default/example/skip-to-content-demo.tsx"],+ category: "undefined",+ subcategory: "undefined",+ chunks: []+ },"page-container-demo": {name: "page-container-demo",type: "components:example",diff --git a/apps/design-system/app/(app)/layout.tsx b/apps/design-system/app/(app)/layout.tsxindex 00fa29d5030..d9d10c8001d 100644--- a/apps/design-system/app/(app)/layout.tsx+++ b/apps/design-system/app/(app)/layout.tsx@@ -1,4 +1,5 @@import { ScrollArea } from 'ui'+import { SkipToContent } from 'ui-patterns/SkipToContent'import { MobileSidebarSheet } from '@/components/mobile-sidebar-sheet'import { SideNavigation } from '@/components/side-navigation'@@ -12,18 +13,22 @@ interface AppLayoutProps {export default async function AppLayout({ children }: AppLayoutProps) {return (<>+ <SkipToContent href="#main" /><TopNavigation /><MobileSidebarSheet />- <main className="flex-1 max-w-site mx-auto w-full border-l border-r border-b">+ <div className="flex-1 max-w-site mx-auto w-full border-l border-r border-b"><div className="flex-1 items-start md:grid md:grid-cols-[220px_minmax(0,1fr)] lg:grid-cols-[240px_minmax(0,1fr)]"><aside className="fixed top-10 z-30 hidden h-[calc(100vh-3rem)] w-full shrink-0 md:sticky md:block border-r"><ScrollArea className="h-full"><SideNavigation /></ScrollArea></aside>- {children}+ {/* Content-only landmark: sidebar must stay outside so skip/Tab don't land in the nav */}+ <main id="main" tabIndex={-1} className="outline-hidden scroll-mt-12 min-w-0">+ {children}+ </main></div>- </main>+ </div><SiteFooter /></>)diff --git a/apps/design-system/config/docs.ts b/apps/design-system/config/docs.tsindex df52dd81aa1..4ad98ae7c13 100644--- a/apps/design-system/config/docs.ts+++ b/apps/design-system/config/docs.ts@@ -247,6 +247,11 @@ export const docsConfig: DocsConfig = {href: '/docs/fragments/single-value-field-array',items: [],},+ {+ title: 'Skip to Content',+ href: '/docs/fragments/skip-to-content',+ items: [],+ },],},{diff --git a/apps/design-system/content/docs/accessibility.mdx b/apps/design-system/content/docs/accessibility.mdxindex 0d71788abac..efdede1da8f 100644--- a/apps/design-system/content/docs/accessibility.mdx+++ b/apps/design-system/content/docs/accessibility.mdx@@ -116,11 +116,13 @@ Individual options inside of a group can be reached by arrow keys (↑ ↓ ←### Jumping ahead-Some keyboard-navigable content may be contain hundreds or thousands of items. Help users jump to specific content with the following mitigation strategies:+Some keyboard-navigable content may contain hundreds or thousands of items. Help users jump to specific content with:- Search and filtering- Pagination or virtualization-- “Jump to” shortcuts to skip ahead+- Skip links and “jump to” shortcuts++Apps with persistent header and sidebar chrome should expose a skip link as the first focusable element. Use the shared [Skip to Content](fragments/skip-to-content) fragment which owns the component API, usage sample, and target landmark contract.## Screen readersdiff --git a/apps/design-system/content/docs/components/button.mdx b/apps/design-system/content/docs/components/button.mdxindex ffa96da53df..b1369d8174a 100644--- a/apps/design-system/content/docs/components/button.mdx+++ b/apps/design-system/content/docs/components/button.mdx@@ -1,6 +1,6 @@---title: Button-description: Displays a button or a component that looks like a button.+description: Displays a button or a link that looks like a button.featured: truecomponent: true---diff --git a/apps/design-system/content/docs/fragments/skip-to-content.mdx b/apps/design-system/content/docs/fragments/skip-to-content.mdxnew file mode 100644index 00000000000..ad224077eb6--- /dev/null+++ b/apps/design-system/content/docs/fragments/skip-to-content.mdx@@ -0,0 +1,53 @@+---+title: Skip to Content+description: Keyboard-accessible skip link that jumps past chrome to the main landmark.+component: true+fragment: true+---++<ComponentPreview name="skip-to-content-demo" peekCode wide />++Keyboard-accessible skip link composed from [Button](../components/button) for apps with persistent header and sidebar chrome. Hidden until focused via Tab, then slides into view so users can jump past navigation to the main landmark.++The preview above shows the focused appearance. In product apps, the link stays off-screen until keyboard focus.++See [Accessibility](../accessibility#jumping-ahead) for more information on when to use skip links, and how they coexist alongside other navigation aids.++## Usage++```tsx+import { SkipToContent } from 'ui-patterns/SkipToContent'+```++```tsx+<SkipToContent href="#main" />++<main id="main" tabIndex={-1} className="scroll-mt-(--header-height) outline-hidden">+ {children}+</main>+```++Place the skip link at the root of the app chrome so Tab reaches it before navigation. The target landmark must be content only. Do not wrap a sidebar inside the same `<main>`, otherwise a Tab after skip will land in the sidebar navigation.++## Props++### `href`++Hash href to the main content landmark, e.g. `#main`.++### `children`++Link label. Defaults to `Skip to content`.++### `className`++Optional classes merged onto the positioning wrapper (useful for demos or layout overrides).++## Target landmark++Callers own the landmark the skip link points at:++- Matching `id`+- `tabIndex={-1}` so Enter moves focus onto the landmark+- `scroll-mt` when a sticky header is present+- `outline-hidden` so the landmark has no visible focus ring. The subsequent Tab will land on the first interactive childdiff --git a/apps/design-system/content/docs/ui-patterns/navigation.mdx b/apps/design-system/content/docs/ui-patterns/navigation.mdxindex a94277fba22..1ccdfaaf1e8 100644--- a/apps/design-system/content/docs/ui-patterns/navigation.mdx+++ b/apps/design-system/content/docs/ui-patterns/navigation.mdx@@ -7,11 +7,13 @@ Supabase has a necessarily complex navigation system to handle multiple products## Components-### NavMenu+### [Nav Menu](../components/nav-menu)A horizontal list of related views within a consistent PageLayout context, allowing for clearer page-level organisation. Activating a NavMenu item should trigger a URL change.-[NavMenu component guidelines](../components/nav-menu)+### [Skip To Content](../fragments/skip-to-content)++Keyboard-accessible skip link for apps with persistent header and sidebar chrome. Hidden until focused via Tab, then slides into view so users can jump past navigation to the main landmark. See [Accessibility](../accessibility#jumping-ahead) for broader context.## Page titlesdiff --git a/apps/design-system/registry/default/example/skip-to-content-demo.tsx b/apps/design-system/registry/default/example/skip-to-content-demo.tsxnew file mode 100644index 00000000000..2fae2626a39--- /dev/null+++ b/apps/design-system/registry/default/example/skip-to-content-demo.tsx@@ -0,0 +1,19 @@+import { SkipToContent } from 'ui-patterns/SkipToContent'++export default function SkipToContentDemo() {+ return (+ <div className="relative w-full overflow-hidden rounded-md border bg-studio">+ <div className="flex items-center border-b px-4 py-3 text-sm text-foreground-muted">+ Demo header / navigation+ </div>+ {/* Preview shows the focused appearance; production hides until Tab */}+ <SkipToContent href="#skip-demo-main" className="relative left-3 top-2 translate-y-0" />+ <main id="skip-demo-main" tabIndex={-1} className="outline-hidden p-6 pt-2">+ <p className="text-sm text-foreground-light">+ Main content landmark. In a real app, Tab once to reveal the skip link, then Enter to jump+ here.+ </p>+ </main>+ </div>+ )+}diff --git a/apps/design-system/registry/examples.ts b/apps/design-system/registry/examples.tsindex 1dfe0661e85..2697a4f176e 100644--- a/apps/design-system/registry/examples.ts+++ b/apps/design-system/registry/examples.ts@@ -1351,6 +1351,11 @@ export const examples: Registry = [type: 'components:example',files: ['example/info-tooltip-demo.tsx'],},+ {+ name: 'skip-to-content-demo',+ type: 'components:example',+ files: ['example/skip-to-content-demo.tsx'],+ },{name: 'page-container-demo',type: 'components:example',diff --git a/apps/docs/app/layout.tsx b/apps/docs/app/layout.tsxindex 6fcd8c1c856..74d9f33e80d 100644--- a/apps/docs/app/layout.tsx+++ b/apps/docs/app/layout.tsx@@ -2,14 +2,15 @@ import 'ui-patterns/ShimmeringLoader/index.css'import '../styles/globals.css'import '../styles/prism-okaidia.css'-import { SkipToContent } from '~/components/SkipToContent'import { GlobalProviders } from '~/features/app.providers'+import { DOCS_CONTENT_CONTAINER_ID } from '~/features/ui/helpers.constants'import { TopNavSkeleton } from '~/layouts/MainSkeleton'import { BASE_PATH, IS_PRODUCTION } from '~/lib/constants'import { getCustomContent } from '~/lib/custom-content/getCustomContent'import { TelemetryTagManager } from 'common'import { genFaviconData } from 'common/MetaFavicons/app-router'import type { Metadata, Viewport } from 'next'+import { SkipToContent } from 'ui-patterns/SkipToContent'import { inter, manrope } from '@/fonts'@@ -53,7 +54,7 @@ const RootLayout = ({ children }: { children: React.ReactNode }) => {return (<html lang="en" className={`${manrope.variable} ${inter.variable}`} suppressHydrationWarning><body>- <SkipToContent />+ <SkipToContent href={`#${DOCS_CONTENT_CONTAINER_ID}`} /><TelemetryTagManager /><GlobalProviders><TopNavSkeleton>{children}</TopNavSkeleton>diff --git a/apps/docs/components/SkipToContent.tsx b/apps/docs/components/SkipToContent.tsxdeleted file mode 100644index 8b31bcb2243..00000000000--- a/apps/docs/components/SkipToContent.tsx+++ /dev/null@@ -1,22 +0,0 @@-import { DOCS_CONTENT_CONTAINER_ID } from '~/features/ui/helpers.constants'-import Link from 'next/link'-import { Button, cn } from 'ui'--const SkipToContent = () => {- return (- <Button- size="tiny"- variant="default"- asChild- className={cn(- 'fixed top-0 left-4 z-[100] w-auto',- '-translate-y-full focus-visible:translate-y-4',- 'transition-transform duration-200 ease-out'- )}- >- <Link href={`#${DOCS_CONTENT_CONTAINER_ID}`}>Skip to content</Link>- </Button>- )-}--export { SkipToContent }diff --git a/apps/docs/layouts/MainSkeleton.tsx b/apps/docs/layouts/MainSkeleton.tsxindex 93cc70fa00c..5ae70b4386c 100644--- a/apps/docs/layouts/MainSkeleton.tsx+++ b/apps/docs/layouts/MainSkeleton.tsx@@ -290,7 +290,7 @@ const Container = memo(function Container({id={DOCS_CONTENT_CONTAINER_ID}tabIndex={-1}className={cn(- 'w-full transition-all ease-out relative scroll-mt-(--header-height)',+ 'w-full transition-all ease-out relative scroll-mt-(--header-height) outline-hidden',// desktop override any margin styles'lg:ml-0',classNamediff --git a/apps/studio/components/layouts/DefaultLayout.tsx b/apps/studio/components/layouts/DefaultLayout.tsxindex 0d507baaca3..734493bb7bb 100644--- a/apps/studio/components/layouts/DefaultLayout.tsx+++ b/apps/studio/components/layouts/DefaultLayout.tsx@@ -1,14 +1,8 @@import { useBreakpoint, useParams } from 'common'import { useRouter } from 'next/router'import { PropsWithChildren, useEffect, useState } from 'react'-import {- buttonVariants,- cn,- ResizablePanel,- ResizablePanelGroup,- SidebarProvider,- usePanelRef,-} from 'ui'+import { ResizablePanel, ResizablePanelGroup, SidebarProvider, usePanelRef } from 'ui'+import { SkipToContent } from 'ui-patterns/SkipToContent'import { BannerStack } from '../ui/BannerStack/BannerStack'import { LayoutHeader } from './Navigation/LayoutHeader/LayoutHeader'@@ -101,19 +95,7 @@ export const DefaultLayout = ({<ProjectContextProvider projectRef={ref}><MobileSheetProvider><div className="flex flex-col h-screen w-screen">- <a- className={cn(- buttonVariants({- size: 'xlarge',- variant: 'primary',- }),- 'absolute top-0 left-1/2 -translate-x-1/2 -translate-y-full focus:translate-y-4'- )}- href="#main"- tabIndex={0}- >- Skip to content- </a>+ <SkipToContent href="#main" />{/* Top Banner */}<AppBannerWrapper /><div className="shrink-0">@@ -144,7 +126,7 @@ export const DefaultLayout = ({maxSize={`${contentMaxSizePercentage}`}defaultSize={`${contentMaxSizePercentage}`}>- <main id="main" className="h-full overflow-y-auto">+ <main id="main" tabIndex={-1} className="h-full overflow-y-auto outline-hidden">{children}</main></ResizablePanel>diff --git a/apps/www/app/(home)/layout.tsx b/apps/www/app/(home)/layout.tsxindex 61677b56677..0e005f310f9 100644--- a/apps/www/app/(home)/layout.tsx+++ b/apps/www/app/(home)/layout.tsx@@ -1,15 +1,19 @@import Footer from '~/components/Footer'import Nav from '~/components/Nav'+import { SkipToContent } from 'ui-patterns/SkipToContent'import { ThemeForcer } from './ThemeForcer'export default function HomeLayout({ children }: { children: React.ReactNode }) {return (<>+ <SkipToContent href="#main" /><ThemeForcer /><Nav hideNavbar={false} /><div className="relative w-full">- <main className="relative min-h-screen">{children}</main>+ <main id="main" tabIndex={-1} className="relative min-h-screen scroll-mt-16 outline-hidden">+ {children}+ </main></div><Footer /></>diff --git a/apps/www/components/Go/GoPageRenderer.tsx b/apps/www/components/Go/GoPageRenderer.tsxindex 968c7b31aba..aa1f021592f 100644--- a/apps/www/components/Go/GoPageRenderer.tsx+++ b/apps/www/components/Go/GoPageRenderer.tsx@@ -3,6 +3,7 @@ import { GoPageRenderer as MarketingPageRenderer } from 'marketing'import type { CustomSectionRenderers } from 'marketing'import Image from 'next/image'import Link from 'next/link'+import { SkipToContent } from 'ui-patterns/SkipToContent'import TweetsSection from './TweetsSection'import type { GoPage } from '@/types/go'@@ -15,6 +16,7 @@ const customRenderers: CustomSectionRenderers = {export default function GoPageRenderer({ page }: { page: GoPage }) {return (<>+ <SkipToContent href="#main" /><nav className="absolute top-0 left-0 right-0 z-10"><div className="max-w-7xl mx-auto flex items-center h-14 px-8"><Link href="/">@@ -24,7 +26,11 @@ export default function GoPageRenderer({ page }: { page: GoPage }) {</div></nav>- <main className="relative min-h-screen pb-16 sm:pb-24">+ <main+ id="main"+ tabIndex={-1}+ className="relative min-h-screen scroll-mt-14 pb-16 outline-hidden sm:pb-24"+ ><MarketingPageRenderer page={page} customRenderers={customRenderers} /></main><footer className="border-t border-muted">diff --git a/apps/www/components/Layouts/Default.tsx b/apps/www/components/Layouts/Default.tsxindex 60e204116ba..aeeb57cd2a4 100644--- a/apps/www/components/Layouts/Default.tsx+++ b/apps/www/components/Layouts/Default.tsx@@ -1,4 +1,5 @@import { cn } from 'ui'+import { SkipToContent } from 'ui-patterns/SkipToContent'import Footer from '@/components/Footer/index'import Nav from '@/components/Nav/index'@@ -25,9 +26,16 @@ const DefaultLayout = (props: Props) => {return (<>+ <SkipToContent href="#main" /><ThemeForcer /><Nav hideNavbar={hideHeader} stickyNavbar={stickyNavbar} />- <main className={cn('relative min-h-screen', className)}>{children}</main>+ <main+ id="main"+ tabIndex={-1}+ className={cn('relative min-h-screen scroll-mt-16 outline-hidden', className)}+ >+ {children}+ </main><Footer className={footerClassName} hideFooter={hideFooter} /></>)diff --git a/packages/ui-patterns/package.json b/packages/ui-patterns/package.jsonindex 3acf9ca2eb1..749f48a721c 100644--- a/packages/ui-patterns/package.json+++ b/packages/ui-patterns/package.json@@ -594,6 +594,14 @@"import": "./src/SimpleCodeBlock/prism.ts","types": "./src/SimpleCodeBlock/prism.ts"},+ "./SkipToContent/SkipToContent": {+ "import": "./src/SkipToContent/SkipToContent.tsx",+ "types": "./src/SkipToContent/SkipToContent.tsx"+ },+ "./SkipToContent": {+ "import": "./src/SkipToContent/index.tsx",+ "types": "./src/SkipToContent/index.tsx"+ },"./SqlToRest/assumptions": {"import": "./src/SqlToRest/assumptions.ts","types": "./src/SqlToRest/assumptions.ts"diff --git a/packages/ui-patterns/src/SkipToContent/SkipToContent.test.tsx b/packages/ui-patterns/src/SkipToContent/SkipToContent.test.tsxnew file mode 100644index 00000000000..357de928b64--- /dev/null+++ b/packages/ui-patterns/src/SkipToContent/SkipToContent.test.tsx@@ -0,0 +1,41 @@+import { render, screen } from '@testing-library/react'+import { describe, expect, it } from 'vitest'++import { SkipToContent } from './SkipToContent'++describe('SkipToContent', () => {+ it('renders a link with the provided href and default label', () => {+ render(<SkipToContent href="#main" />)++ const link = screen.getByRole('link', { name: 'Skip to content' })+ expect(link).toHaveAttribute('href', '#main')+ })++ it('allows a custom label', () => {+ render(<SkipToContent href="#docs-content">Skip to docs</SkipToContent>)++ expect(screen.getByRole('link', { name: 'Skip to docs' })).toHaveAttribute(+ 'href',+ '#docs-content'+ )+ })++ it('is off-screen until keyboard focus and slides in on focus-within', () => {+ const { container } = render(<SkipToContent href="#main" />)++ const wrapper = container.firstElementChild as HTMLElement+ expect(wrapper.className).toContain('-translate-y-full')+ expect(wrapper.className).toContain('focus-within:translate-y-[10px]')+ expect(wrapper.className).toContain('bg-background')+ expect(wrapper.className).toContain('w-fit')+ expect(wrapper.className).toContain('left-[10px]')+ })++ it('uses an unmodified default Button for hover and fill styles', () => {+ render(<SkipToContent href="#main" />)++ const link = screen.getByRole('link', { name: 'Skip to content' })+ expect(link.className).not.toContain('bg-surface-300')+ expect(link.className).not.toContain('hover:bg-secondary')+ })+})diff --git a/packages/ui-patterns/src/SkipToContent/SkipToContent.tsx b/packages/ui-patterns/src/SkipToContent/SkipToContent.tsxnew file mode 100644index 00000000000..7f8bdc2555d--- /dev/null+++ b/packages/ui-patterns/src/SkipToContent/SkipToContent.tsx@@ -0,0 +1,37 @@+import { type ReactNode } from 'react'+import { Button, cn } from 'ui'++export interface SkipToContentProps {+ /** Hash href to the main content landmark, e.g. `#main`. */+ href: string+ children?: ReactNode+ className?: string+}++/**+ * Keyboard-accessible skip link. Hidden until focused via Tab, then slides into view.+ *+ * Callers must provide a matching landmark target with `id`, `tabIndex={-1}`,+ * `outline-hidden`, and `scroll-mt` when a sticky header is present. The+ * landmark itself should not show a visible focus ring.+ */+function SkipToContent({ href, children = 'Skip to content', className }: SkipToContentProps) {+ return (+ <div+ className={cn(+ // Opaque plate so default Button muted/selection fills composite like any other control.+ // w-fit: plate is a block div by default and would otherwise span the full content column.+ 'fixed top-0 left-[10px] z-[100] w-fit rounded-md bg-background',+ '-translate-y-full focus-within:translate-y-[10px]',+ 'transition-transform duration-200 ease-out',+ className+ )}+ >+ <Button size="tiny" variant="default" asChild>+ <a href={href}>{children}</a>+ </Button>+ </div>+ )+}++export { SkipToContent }diff --git a/packages/ui-patterns/src/SkipToContent/index.tsx b/packages/ui-patterns/src/SkipToContent/index.tsxnew file mode 100644index 00000000000..7c3cb3b32fa--- /dev/null+++ b/packages/ui-patterns/src/SkipToContent/index.tsx@@ -0,0 +1 @@+export { SkipToContent, type SkipToContentProps } from './SkipToContent'