import { Meta, Source } from '@storybook/addon-docs/blocks';

<Meta title="Prompts/Snackbar/Accessibility" />

# Accessibility

## Announcements

Snackbar uses `role="status"`, `aria-live="polite"` and `aria-atomic="true"` for every sentiment,
including negative. Showing a message requests a polite announcement without moving focus.
There is no live region while the Provider is idle.

The localised hint “Press Escape to dismiss.” follows the message, including on touch-only devices.

## Keyboard and dismissal

- The action follows normal tab order. Buttons support Enter and Space; links support Enter.
- Escape dismisses unless another overlay has already handled it.
- Desktop has a close IconButton labelled “Close”. On small screens it is hidden and not focusable.
- Swipe or drag down at least half the surface height to dismiss. Shorter or cancelled gestures return to place.

There is no shortcut to reach the action. Do not make Snackbar the only way to access an essential action.

## Reduced motion

Reduced motion removes entry/exit movement and scale, and swipe transitions.

## Media

Include essential meaning in the message: custom media is outside its live region.
Hide decorative icons from assistive technology:

<Source
  dark
  code={`import { Button, SnackbarProvider, useSnackbar } from '@transferwise/components';
import { Card } from '@transferwise/icons';

function CardFeedback() {
  const createSnackbar = useSnackbar();

  return (
    <Button v2 size="md" onClick={() => createSnackbar({
      text: 'Card added to your wallet',
      media: <Card aria-hidden />,
    })}>
      Show card confirmation
    </Button>
  );
}

export default function App() {
  return (
    <SnackbarProvider>
      <CardFeedback />
    </SnackbarProvider>
  );
}`}
/>
