Skip to content

Field Label ​

catnip-field-label names the control whose id you pass in html-for, and a click on it reaches that control. Its required marker and disabled styling are visual only: you set the control's own required and disabled state.

Screen readers ​

  • The label renders inside the element's shadow root, where a for attribute can't reach your control. So the element finds the control with the html-for id in the same page (or the shadow root it sits in) and adds its own id to the control's aria-labelledby. Without an id, it gets a generated one (catnip-field-label-1, …). IDs you already have in aria-labelledby stay; the element takes out only the one it added, when html-for changes or the label is removed.
  • A click on the label focuses the control, or toggles it for a checkbox or radio, like a native <label>.
  • Catnip fields (catnip-input, catnip-dropdown, catnip-checkbox, …) with that id find the label themselves and connect it to their inner control; nothing is written on their host.
  • Only the title, the optional hint and the required marker are inside the <label>. The info button and the action / suffix content sit beside it, so they aren't part of the control's name.
  • info renders a <button> named “More information about {title}” (locale key fieldLabel.moreInfo) and described by the info text. The text shows as a tooltip on hover and focus, and Escape hides it. Clicking the button doesn't move focus to the control.
  • The required marker is visual only.
  • Optional required-screen-reader-text adds a supplemental hidden phrase only when non-empty; it does not replace aria-required on the control.

What you own ​

  • Association: Set html-for on the label and a matching id on the control, in the same document or shadow root. Expect aria-labelledby on the control to include the label's id.
  • Required: When required is true, set required and/or aria-required="true" on the control — the label marker is visual only.
  • Disabled: When disabled is set on the label for visual coordination, also set native disabled on the control.

WCAG 2.2 AA ​

CriterionThe componentYou
1.3.1 Info and relationships, 4.1.2 Name, role, valueNames the control through aria-labelledby and forwards clicks; the info icon is a named buttonSet required / aria-required and disabled on the control
2.5.3 Label in nameThe name is the visible title; action and suffix content stay out of it—
3.3.2 Labels or instructionsRequired and optional markersMark required or optional fields consistently

This table says who handles what. It isn't a conformance claim: WCAG conformance is claimed for a page or a process.

Known issues ​

  • The control has to be in the same document or shadow root as the label, since the label finds it by id.

Catnip Design System by Signicat