Design System: Improve icon button example accessibility (#50783)

## 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>
This commit is contained in:
Gildas GarciaandDanny White authored and GitHub committed 2026-09-28 09:56:54 +02:00
1 parent c856de8fda
commit 93a032c90d
3 files changed
+32 -9

No files matched your search

+5 -1
View File
@@ -119,6 +119,9 @@ const buttonVariants = cva(
rounded: {
true: 'rounded-full',
},
iconOnly: {
true: 'hit-area-1 w-6.5',
},
},
// Match <Button size="tiny"> so raw buttonVariants({ variant }) keeps sizing.
// Fixed icon shells that omit size must override padding (e.g. px-0 with h/w-[30px]).
@@ -182,7 +185,7 @@ export interface ButtonProps
extends
React.ButtonHTMLAttributes<HTMLButtonElement>,
// omit 'disabled' as it is included in HTMLButtonElement
Omit<ButtonVariantProps, 'disabled'>,
Omit<ButtonVariantProps, 'disabled' | 'iconOnly'>,
LoadingVariantProps {
asChild?: boolean
variant?: ButtonVariantProps['variant']
@@ -266,6 +269,7 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
focusableWhenDisabled,
block,
rounded,
iconOnly: children == null || children === false,
}),
className
)}