Files
supabase/apps/design-system/registry/default/example/copy-tooltips.tsx
hasithasandun a0a17e17e8 fix(design-system): improve responsiveness of copywriting components (#46034)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Bug fix

## What is the current behavior?

On mobile devices, the component previews in the Design System
documentation site (`/apps/design-system`) overflow horizontally and
clip off the screen. This is caused by rigid `p-10` padding on the
preview container and hardcoded widths (`w-[400px]`, `w-[300px]`) and
inflexible flex layouts (`flex-row gap-16`) within the example
components.

## What is the new behavior?

The component previews are now fully responsive and render correctly on
mobile viewports:
- Updated the main preview container padding to be responsive (`p-4
sm:p-10`) in `component-preview.tsx` to maximize available space on
mobile.
- Replaced fixed widths with fluid max-widths (`w-full max-w-[400px]`)
in various copywriting component examples.
- Updated flex layouts that previously forced single rows to wrap
(`flex-wrap`) and scale down gaps on smaller screens (`gap-8
sm:gap-16`).
- Added `shrink-0` to icons in alerts to prevent them from squishing
when text wraps on narrow screens.

Affected components:
- `component-preview.tsx`
- `copy-button-verbs.tsx`
- `copy-confirmations.tsx`
- `copy-error-messages.tsx`
- `copy-form-labels.tsx`
- `copy-loading-states.tsx`
- `copy-success-messages.tsx`
- `copy-tooltips.tsx`

## Screenshots
### Mobile (Layout Bug - Before)
<!-- Add your broken mobile layout screenshot here -->
<img width="383" height="673" alt="Image"
src="https://github.com/user-attachments/assets/faeba844-c137-4ab2-aa2c-2299e5ae5bf0"
/>

<img width="377" height="667" alt="Image"
src="https://github.com/user-attachments/assets/e995289c-8c4c-4ba2-8fac-f36bfe869cd7"
/>

<img width="376" height="671" alt="Image"
src="https://github.com/user-attachments/assets/b08afcfc-cc03-4087-9bdc-6082ed4a0c0a"
/>

### Mobile (Responsive - After)
<!-- Add your fixed mobile layout screenshot here -->
<img width="375" height="672" alt="Image"
src="https://github.com/user-attachments/assets/54f68165-1e42-4f96-b9b8-cc6928909cbf"
/>

<img width="378" height="673" alt="Image"
src="https://github.com/user-attachments/assets/816e7103-3184-4593-9847-896e3e4736ff"
/>

<img width="372" height="665" alt="Image"
src="https://github.com/user-attachments/assets/97ba8f70-5340-4d15-92ee-1a032ee7d935"
/>

## Additional context

This addresses the layout bugs on the Design System Copywriting
documentation page.

Fixes #46033


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Style**
* Improved responsiveness across the design system with updated layout
and spacing utilities.
* Replaced several fixed-width examples with flexible full-width
containers constrained by max-widths for consistent sizing.
* Adjusted preview padding to use responsive values for better mobile
presentation.
  * Enabled flex wrapping and refined gap sizes for multi-row layouts.
* Prevented icons from shrinking in flex rows to preserve alignment and
visual consistency.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46034?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-17 11:49:55 +11:00

52 lines
1.7 KiB
TypeScript

'use client'
import { Info } from 'lucide-react'
import { Button, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from 'ui'
export default function CopyTooltips() {
return (
<div className="flex flex-row flex-wrap gap-8 sm:gap-20">
<div className="flex flex-col gap-4">
<span className="text-xs text-foreground-muted">Bad Example</span>
<div className="flex flex-row gap-8 items-center">
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="text"
className="flex items-center px-1.5"
icon={<Info size={20} strokeWidth={1.5} />}
aria-label="More info"
/>
</TooltipTrigger>
<TooltipContent>
<p>This is a toggle switch</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
</div>
<div className="flex flex-col gap-4">
<span className="text-xs text-foreground-muted">Good Example</span>
<div className="flex flex-row gap-8 items-center">
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="text"
className="flex items-center px-1.5"
icon={<Info size={20} strokeWidth={1.5} />}
aria-label="More info"
/>
</TooltipTrigger>
<TooltipContent>
<p>Restricts access based on user policies</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
</div>
</div>
)
}