// Copyright (c) Meta Platforms, Inc. and affiliates. 'use client'; import {VisuallyHidden} from '@astryxdesign/core/VisuallyHidden'; import {IconButton} from '@astryxdesign/core/IconButton'; import {Card} from '@astryxdesign/core/Card'; import {HStack, VStack} from '@astryxdesign/core/Layout'; import {Text} from '@astryxdesign/core/Text'; import {Icon} from '@astryxdesign/core/Icon'; import {useToast} from '@astryxdesign/core/Toast'; import {useImperativeAlertDialog} from '@astryxdesign/core/AlertDialog'; import { ArrowDownTrayIcon as DownloadIcon, ShareIcon, TrashIcon as DeleteIcon, } from '@heroicons/react/24/outline'; import {SpeakerWaveIcon as AudioIcon} from '@heroicons/react/24/solid'; const actions = [ {label: 'Download', icon: DownloadIcon}, {label: 'Share', icon: ShareIcon}, {label: 'Delete', icon: DeleteIcon}, ] as const; /** * VisuallyHidden is invisible by design, so this hero teaches the concept by * contrast: the icon-only buttons are all a sighted user sees, while the * caption spells out the accessible name each one exposes. A live * region below announces the same names to assistive tech, * so the demo genuinely exercises the component it documents. */ export default function VisuallyHiddenShowcase() { const showToast = useToast(); const confirm = useImperativeAlertDialog(); return ( What you see {actions.map(({label, icon}) => ( } variant="ghost" onClick={() => label === 'Delete' ? confirm.show({ title: 'Delete this item?', description: "This demo won't delete anything.", actionLabel: 'Delete', onAction: () => { confirm.hide(); // Demo only: replace this toast with the call that performs the action. showToast({ body: 'Demo: the item would be deleted here', }); }, }) : showToast({ body: `Demo: the ${label.toLowerCase()} action would run here`, }) } /> ))} What a screen reader hears {actions.map(({label}) => ( {label}, button ))} {/* A real live region: silent to sighted users, announced by AT. */} Actions available: Download, Share, Delete. {confirm.element} ); }