<!-- index: /slotted/llms.txt -->
# visually-hidden

`data-ui="visually-hidden"` · Hides content visually, keeps it for readers.

## Minimal example

Example

```tsx
import { Button } from '@slotted/react/button';
import { Glyph } from '@slotted/react/icon';
import { Inline } from '@slotted/react/inline';
import { VisuallyHidden } from '@slotted/react/visually-hidden';

export default function VisuallyHiddenBasic() {
  return (
    <Inline>
      <Button tone="danger" variant="outline">
        <Glyph name="trash" />
        <VisuallyHidden>Delete invoice INV-20418</VisuallyHidden>
      </Button>
    </Inline>
  );
}
```

## Props

| Name | Type | Default | Applies to | Description |
| --- | --- | --- | --- | --- |
| `focusable` | `boolean` | false | VisuallyHidden | Stops hiding the content while focus is inside it. |
| `render` | `(props) => ReactNode` | — | VisuallyHidden | Renders a different element. |
| `children` | `ReactNode` | — | VisuallyHidden | Content exposed only to assistive technology. |
| `className` | `string` | — | VisuallyHidden | Class names, forwarded untouched. |

## Rules

- The content stays in the accessibility tree: the stylesheet clips it rather than applying display: none or visibility: hidden.
- The content costs no space. The element is taken out of flow and held to one pixel, so a control that gains an accessible name this way is the size it was, and a hidden span between two flex items does not become a second gap.
- A screen reader reads the content in document order, so it belongs where it would be read, not at the end of the document.
- The whole string stays in the DOM as text. Hidden text is content, not decoration.
- focusable is for content a sighted keyboard user must be able to reach, such as a skip link. While focus is inside, the hiding rule stops matching and the element renders as it was written — the component paints nothing on the revealed state, so the appearance of a skip link belongs to the link.
- The component adds no role and no class. Wrap it in the element that carries the semantics, or hand the wiring to that element with render. Select it in the DOM as [data-ui="visually-hidden"].

## Examples

### An accessible name for an icon-only control

Excerpt — not a complete module

```tsx
<button type="button">
  <TrashIcon aria-hidden="true" />
  <VisuallyHidden>Delete invoice</VisuallyHidden>
</button>;
```

### A skip link that appears on focus

Excerpt — not a complete module

```tsx
<VisuallyHidden focusable render={(props) => <a {...props} href="#main" />}>
  Skip to content
</VisuallyHidden>;
```

### count.tsx

Example

```tsx
import { Glyph } from '@slotted/react/icon';
import { Inline } from '@slotted/react/inline';
import { Stack } from '@slotted/react/stack';
import { Text } from '@slotted/react/typography';
import { VisuallyHidden } from '@slotted/react/visually-hidden';

export default function VisuallyHiddenCount() {
  return (
    <Stack gap={3}>
      <Inline gap={2}>
        <Glyph name="bell" />
        <Text numeric="tabular" weight="semibold">
          3
        </Text>
        <VisuallyHidden>unread notifications</VisuallyHidden>
      </Inline>
      <Text size="sm" tone="muted">
        Visible: a bell and 3. Read aloud: 3 unread notifications.
      </Text>
    </Stack>
  );
}
```

### skip-link.tsx

Example

```tsx
import { Stack } from '@slotted/react/stack';
import { Heading, Text } from '@slotted/react/typography';
import { VisuallyHidden } from '@slotted/react/visually-hidden';

export default function VisuallyHiddenSkipLink() {
  return (
    <Stack gap={3}>
      <VisuallyHidden focusable render={(props) => <a {...props} href="#orders-today" />}>
        Skip to the orders
      </VisuallyHidden>
      <Text size="sm" tone="muted">
        The skip link appears above this text while it has focus.
      </Text>
      <Heading id="orders-today" level={2} size="sm" tabIndex={-1}>
        Orders placed today
      </Heading>
    </Stack>
  );
}
```

### table-heading.tsx

Example

```tsx
import { Button } from '@slotted/react/button';
import { Glyph } from '@slotted/react/icon';
import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableColumnHeader,
  TableContent,
  TableHead,
  TableRow,
  TableRowHeader,
} from '@slotted/react/table';
import { VisuallyHidden } from '@slotted/react/visually-hidden';

const ORDERS = [
  { id: 'SO-10421', total: '$1,240.00' },
  { id: 'SO-10422', total: '$860.50' },
  { id: 'SO-10423', total: '$3,410.25' },
] as const;

export default function VisuallyHiddenTableHeading() {
  return (
    <Table columns={3}>
      <TableContent>
        <TableCaption>Orders placed today</TableCaption>
        <TableHead>
          <TableRow>
            <TableColumnHeader>Order</TableColumnHeader>
            <TableColumnHeader numeric>Total</TableColumnHeader>
            <TableColumnHeader>
              <VisuallyHidden>Actions</VisuallyHidden>
            </TableColumnHeader>
          </TableRow>
        </TableHead>
        <TableBody>
          {ORDERS.map((order) => (
            <TableRow key={order.id} value={order.id}>
              <TableRowHeader>{order.id}</TableRowHeader>
              <TableCell numeric>{order.total}</TableCell>
              <TableCell>
                <Button tone="danger" variant="ghost">
                  <Glyph name="trash" />
                  <VisuallyHidden>Cancel order {order.id}</VisuallyHidden>
                </Button>
              </TableCell>
            </TableRow>
          ))}
        </TableBody>
      </TableContent>
    </Table>
  );
}
```
