Visually Hidden Input
A hidden input that remains accessible to assistive technology and maintains form functionality.
Installation
pnpm dlx shadcn@latest add @diceui/visually-hidden-inputUsage
import { VisuallyHiddenInput } from "@diceui/visually-hidden-input"
export function CustomForm() {
const [checked, setChecked] = React.useState(false)
const controlRef = React.useRef(null)
return (
<form>
<button
ref={controlRef}
onClick={() => setChecked(!checked)}
aria-checked={checked}
role="checkbox"
>
{checked ? "✓" : ""}
</button>
<VisuallyHiddenInput
type="checkbox"
checked={checked}
control={controlRef.current}
/>
</form>
)
}API Reference
VisuallyHiddenInput
A hidden input that maintains form functionality while being visually hidden.
Prop
Type
Credits
- Radix UI - Checkbox bubble input