Component reference
VisuallyHidden
Visible controls with additional screen-reader context.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
Accessible compact controls
The search input is named by visually hidden text.
Width adapts to the available space
"use client";
import { useState } from "react";
import {
Button,
VisuallyHidden,
Input,
Card,
CardHeader,
CardTitle,
CardContent
} from "@pimolu/react";
export function DemoExample() {
const [page, setPage] = useState(1);
const [query, setQuery] = useState("");
return (
<Card>
<CardHeader>
<CardTitle>Accessible compact controls</CardTitle>
</CardHeader>
<CardContent>
<div
className="grid gap-5 min-w-0"
>
<div className="flex flex-wrap items-center gap-3 min-w-0">
<Button
iconOnly
appearance="outline"
disabled={page === 1}
onClick={() => setPage(page - 1)}
>
<span
aria-hidden="true"
>←</span>
<VisuallyHidden>
Previous page
</VisuallyHidden>
</Button>
<span
role="status"
>Page {
page
}</span>
<Button
iconOnly
appearance="outline"
onClick={() => setPage(page + 1)}
>
<span
aria-hidden="true"
>→</span>
<VisuallyHidden>
Next page
</VisuallyHidden>
</Button>
</div>
<VisuallyHidden id="example-hidden-search-label">Search the documentation</VisuallyHidden>
<Input
aria-labelledby="example-hidden-search-label"
placeholder="Search documentation…"
value={query}
onValueChange={setQuery}
fullWidth
/>
<p
className="text-sm text-muted leading-relaxed"
>{
query
? `Searching locally for “${query}”.`
: "The search input is named by visually hidden text."
}</p>
</div>
</CardContent>
</Card>
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Labels
Icon-only controls keep a real accessible name without adding visible text.
Focusable skip link
Tab into the page: the link is clipped, then becomes a fixed panel at the top-left while focused.
Live regions
A polite status can stay hidden; screen readers announce it when the text changes.
Usage
Use visually hidden text for necessary names, not to conceal essential instructions from sighted users.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluVisuallyHiddenProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
as | ElementType | undefined | `span` | Element rendered by the wrapper. Defaults to `span`. |
focusable | boolean | undefined | false | Reveal the content when it receives focus and make it a tab stop. Use it for skip links; leave it off for labels that only assistive technology should read. |
href | string | undefined | — | Link target for the skip-link use case (`as="a"`). Layout primitives keep native attribute types narrow because `as` is not generic. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
children | ReactNode | — | Standard React/HTML attribute. |
onChange | ChangeEventHandler<HTMLElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLElement> | undefined | — | Standard React/HTML attribute. |
asElementType | undefinedDefault: `span`
Element rendered by the wrapper. Defaults to `span`.
focusableboolean | undefinedDefault: false
Reveal the content when it receives focus and make it a tab stop. Use it for skip links; leave it off for labels that only assistive technology should read.
hrefstring | undefinedNo default extracted.
Link target for the skip-link use case (`as="a"`). Layout primitives keep native attribute types narrow because `as` is not generic.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
childrenReactNodeNo default extracted.
Standard React/HTML attribute.
onChangeChangeEventHandler<HTMLElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLElement> | undefinedNo default extracted.
Standard React/HTML attribute.
Accessibility
- Confirm hidden text contributes to the accessible name without becoming a duplicate announcement.