Help field

field-help is a family of five styled form fields (HintHelpField, TooltipField, CounterField, DescriptionField, LinkField) that each attach a different kind of help text to a label and input, using ai2 design tokens and sizes sm to xl. All help text is wired into aria-describedby so assistive technology announces it.

componentstyledfieldregistry-item.json
Help field
LIVE · running in a sandboxed iframe
Installed with shadcn add · 2 workarounds · theme from registry.json
  • applied the registry's theme (tokens, fonts and CSS from the registry preview settings)
  • installed base item https://ai2.design/r/tokens.json (registry preview settings)
See how it was built

Installation

pnpm dlx shadcn@latest add @ai2/field-help

Requires @ai2 in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { HintHelpField, TooltipField, CounterField, DescriptionField, LinkField } from '@/components/ui/field-help'export default function Example() {  return (    <div className='flex flex-col gap-4'>      <HintHelpField size='md' label='Username' description='Three to twenty characters.' />      <TooltipField size='md' label='Display name' description='This is the name other people see.' />      <CounterField size='md' label='Bio' description='A short line about yourself.' />      <DescriptionField size='md' label='Workspace slug' description='Lowercase letters, numbers and dashes only.' />      <LinkField size='md' label='API key' description='Paste the secret key from your dashboard.' helpHref='/docs/api-keys' />    </div>  )}
  • Use HintHelpField when a short format rule or example should always be visible under an input.
  • Use TooltipField when the help is optional and would clutter the form, so it appears only on demand beside the label.
  • Use CounterField when the input has a hard character limit and users need live feedback on remaining length.
  • Use DescriptionField or LinkField when the guidance is long or links to documentation, such as a naming rule or where to find an API key.

Examples

Signup form with a hint

A required-format username field using the hint variant, with a custom label and hint text.

signup-form-with-a-hint.tsx
import { HintHelpField } from '@/components/ui/field-help'export function SignupUsername() {  return <HintHelpField label='Username' description='Two to thirty characters. Letters and spaces only.' size='lg' />}

Profile form with a tooltip

A compact name field whose help is revealed from an icon beside the label.

profile-form-with-a-tooltip.tsx
import { TooltipField } from '@/components/ui/field-help'export function ProfileName() {  return <TooltipField label='Display name' description='This is the name other people see on your profile.' size='sm' />}

Bio with a live counter

A bio field that counts characters against a 60 character limit and becomes invalid when exceeded.

bio-with-a-live-counter.tsx
import { CounterField } from '@/components/ui/field-help'export function BioField() {  return <CounterField label='Bio' description='A short line about yourself.' size='md' />}

API key with documentation link

A secret key field whose help text links to the relevant documentation page.

api-key-with-documentation-link.tsx
import { LinkField } from '@/components/ui/field-help'export function ApiKeyField() {  return <LinkField label='API key' description='Paste the secret key from your dashboard.' helpHref='/docs/agents' size='md' />}

API reference

PropTypeDefaultDescription
classNamestring—Extra classes merged onto the outer field wrapper div via cn. Available on all five components.
size'sm' | 'md' | 'lg' | 'xl''md'Scales the gap, label text, help text and control height. Exported as the StyledSize type. Available on all five components.
labelReact.ReactNodeHintHelpField and TooltipField: 'Display name'; CounterField: 'Bio'; DescriptionField: 'Workspace slug'; LinkField: 'API key'Content of the label element bound to the input via htmlFor. Available on all five components.
descriptionReact.ReactNodeHintHelpField: 'Two to thirty characters. Letters and spaces only.'; TooltipField: 'This is the name other people see on your profile.'; CounterField: 'A short line about yourself.'; DescriptionField: a long workspace slug rule; LinkField: 'Paste the secret key from your dashboard.'Help text. Passing null or false removes the visible help block in HintHelpField, CounterField, DescriptionField and LinkField, and its id is dropped from aria-describedby. TooltipField always renders the text in a screen-reader-only span.
helpHrefstring'/docs/agents'Only on LinkField. The href of the 'Where do I find it?' link inside the description.

Accessibility

  • Each label is bound to its input with htmlFor and a useId-generated id, so the accessible name is always set.
  • All help text is referenced from aria-describedby. In TooltipField the description is in a visually hidden span, so it is read even when the popover is closed.
  • CounterField sets aria-invalid on the input when the value exceeds 60 characters, and the counter has aria-live='polite' so changes are announced.
  • The TooltipField trigger is a real button with aria-label 'Show help for this field' and aria-expanded reflecting visibility; it opens on focus as well as hover.
  • Invalid state is shown with aria-invalid styling on the control, so the danger appearance is tied to the semantic attribute.
  • The LinkField link and the TooltipField button both have visible focus rings using the ring token.
  • Colors come only from ai2 tokens, so contrast follows the token theme.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Help field" component (ai2/field-help) from its shadcn registry.1. Install it with: npx shadcn@latest add @ai2/field-help2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: className, size, label, description, helpHref.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { HintHelpField, TooltipField, CounterField, DescriptionField, LinkField } from '@/components/ui/field-help'export default function Example() {  return (    <div className='flex flex-col gap-4'>      <HintHelpField size='md' label='Username' description='Three to twenty characters.' />      <TooltipField size='md' label='Display name' description='This is the name other people see.' />      <CounterField size='md' label='Bio' description='A short line about yourself.' />      <DescriptionField size='md' label='Workspace slug' description='Lowercase letters, numbers and dashes only.' />      <LinkField size='md' label='API key' description='Paste the secret key from your dashboard.' helpHref='/docs/api-keys' />    </div>  )}```

Files & dependencies

  • registry/ai2/styled/field-help.tsx→ components/ui/field-help.tsx
dependencieslucide-react@^1.23.0
registryDependencies@ai2/tokens

Looks similar, elsewhere