Skip to content

The open alternative to Salesforce, designed for AI.

1.9 KB
Raw Blame
---
title: VisuallyHidden
description: Keep supporting text available to assistive technology without displaying it visually.
---

import { PageBanner } from "/snippets/page-banner.mdx"

import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';

import VisuallyHiddenReference from '/snippets/ui/generated/accessibility/visually-hidden.mdx';

## Overview

`VisuallyHidden` renders a visually hidden `span`. Its content stays in the accessibility tree and can supply an accessible name. It accepts native span props, a span ref, and Base UI `render` composition. Import `VisuallyHiddenProps` from the same entry point.

<StoryEmbed
  storyId="ui-accessibility-visuallyhidden--display"
  title="Visually hidden example"
  height={100}
/>

## Usage

```tsx
import { Button } from 'twenty-ui/primitives/input';
import { VisuallyHidden } from 'twenty-ui/primitives/accessibility';
import { IconPlus } from 'twenty-ui/icon';

type AddRecordActionProps = { onAdd: () => void };

export const AddRecordAction = ({ onAdd }: AddRecordActionProps) => (
  <Button onClick={onAdd}>
    <IconPlus aria-hidden />
    <VisuallyHidden>Add record</VisuallyHidden>
  </Button>
);
```

Use a visible label when space permits. For controls that already accept `aria-label`, that attribute is another way to supply an accessible name.

## Hidden content

Place supporting text inside the wrapper. Avoid placing focusable controls inside it: the wrapper stays visually hidden when its children receive focus. It does not add a live region, remove content from assistive technology, or hide confidential data.

Use `id` to associate hidden descriptions with `aria-describedby`. Native attributes, `className`, `style`, and `ref` target the hidden span or the element supplied through `render`. See [accessibility](/ui/accessibility) for labeling and announcement patterns.

## Props

<VisuallyHiddenReference />

<PageBanner illustration="page-cover-accessibility" />