mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 10:25:06 +03:00
## Problem The Icon only button example lacks some accessibility features: - no `aria-label` for screen readers - no tooltip for sighted users ## Solution Add both with comments explaining the reasons ## Review instructions See https://design-system-imfc534k0-supabase.vercel.app/design-system/docs/components/button#only-an-icon <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Clarified icon-only button guidance: use a tooltip for sighted users and an accessible label for screen readers. When the tooltip repeats the button’s label, prevent it from being announced twice. * Added guidance to use a square button container and increase the tap target by 8px. Updated the icon-button example to demonstrate a “View logs” tooltip and accessible labeling. * **New Features** * Icon-only buttons now use a compact square layout with an expanded tap target. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Danny White <3104761+dnywh@users.noreply.github.com>
22 lines
694 B
TypeScript
22 lines
694 B
TypeScript
import { ExternalLink } from 'lucide-react'
|
|
import { Button, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
export default function ButtonIcon() {
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
variant="outline"
|
|
icon={<ExternalLink />}
|
|
// Match tooltip content for screen readers
|
|
aria-label="View logs"
|
|
// Tooltip repeats the label; clear describedby so screen readers don't hear it twice
|
|
// Skip this if the tooltip adds information beyond the label
|
|
aria-describedby={undefined}
|
|
></Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>View logs</TooltipContent>
|
|
</Tooltip>
|
|
)
|
|
}
|