Skip to Content
Neshel-UI
Components

VisuallyHidden

Content for assistive technology that is hidden visually.

Server-compatible (no "use client")

Purpose

VisuallyHidden hides content visually while keeping it available to screen readers — extra context for icons, counts or abbreviated text.

Import

import.tsx
import { VisuallyHidden } from "@neshel-ui/components";

Usage

Preview: visually-hidden-icon
Preview theme
visually-hidden-icon.tsx
import { Button, VisuallyHidden } from "@neshel-ui/components";
import { Inline } from "@neshel-ui/layout";
import { Bell } from "lucide-react";

export default function VisuallyHiddenIcon() {
  return (
    <Inline space="3" align="center">
      <Button variant="outline">
        <Bell aria-hidden="true" />
        <VisuallyHidden>Notifications</VisuallyHidden>
        <span aria-hidden="true">3</span>
        <VisuallyHidden>(3 unread)</VisuallyHidden>
      </Button>
    </Inline>
  );
}

API

VisuallyHiddenProps

VisuallyHiddenProps
PropTypeDefaultDescription
asChildboolean—Hide the single child element instead of rendering a span.
refRef<HTMLSpanElement>——

Also accepts the props of: React DOM attributes.

Accessibility

Hidden content is still read and still focusable if it contains focusable elements. Do not hide interactive controls with it. For an icon-only button, an aria-label is usually simpler.

Common mistakes

  • Using it to hide content from everyone: use hidden or display: none instead.
Edit on GitHub

On this page