Field Label
A field label associates visible copy with a form control. Use catnip-field-label when Catnip does not own the control — for example a native <select>, a third-party widget, or a custom layout — and you want the same label row as Input, Date Input, Number Input, Phone Input, and Chip Input.
Overview
catnip-field-label renders a label row: a native <label> with the title, optional hint and required marker, followed by an optional info button and the action / suffix slots. Those sit beside the <label>, so they aren't part of the field's name.
When to use
- Custom controls — pair with any element that accepts an
idandaria-labelledbyand can be referenced fromhtml-for. - Composite inputs — prefer
label/labelslot props oncatnip-input,catnip-input-date,catnip-input-number,catnip-input-phone, andcatnip-input-chipwhen Catnip owns the field; those components embed the same label primitive and wirefor/idfor you.
Layout
- Default spacing — the root includes bottom margin (label→control gap) unless
flushis set. - Alignment —
left(default),center, orrightfor the label block. - Size —
morltypography. Small composite fields use the medium label treatment.
Live example
Guidelines
When to use standalone vs composite inputs
- Use
catnip-field-labelwhen the control is not a Catnip input — native elements, third-party widgets, file uploads, grouped custom layouts. - Use composite label props on
catnip-input,catnip-input-date,catnip-input-number,catnip-input-phone, andcatnip-input-chipwhen Catnip owns the field. Those components embed the same label and wirehtml-for/idautomatically.
Wiring
<catnip-field-label html-for="country" required>
Country
</catnip-field-label>
<select id="country" required aria-required="true">…</select>html-foron the label must match the controlid. The label sits in a shadow root, so it names the control by adding its ownidto the control'saria-labelledby, and forwards clicks to it. See Accessibility.- Catnip fields work the same way:
<catnip-field-label html-for="email">names<catnip-input id="email">when the input has nolabelof its own. requiredon the label is visual only — setrequiredand/oraria-required="true"on the control.disabledon the label coordinates appearance only — set nativedisabledon the control.
Slots
action— end-aligned link or button (e.g. “Don’t know address?”). Project withslot="action"on a child such ascatnip-link.suffix— custom trailing content when you are not using theinfoprop. Wheninfois non-empty, it wins andsuffixis omitted.
Composite inputs use label.action and label.suffix for the same patterns.
Info tooltip
Pass a plain string to info to render an info button beside the title. It's named “More information about {title}” and described by the text, which shows as a tooltip on hover and focus. For a custom anchor or tooltip body, leave info empty and use the suffix slot with catnip-tooltip; give your anchor a name and connect its description (see Tooltip accessibility).
Spacing
- Default — label includes bottom margin to the control.
flush— use when a parent wrapper already defines vertical rhythm (flexgap, stacked fields).
Helper / error copy
Standalone labels do not include supporting text. For Catnip-owned fields, use supporting-text on catnip-input, catnip-input-date, catnip-input-number, catnip-input-phone, or catnip-input-chip. For custom controls, use your own helper markup below the field until a public supporting-text primitive is available.