--- name: label-usage description: > Use after component-usage-ux when an app needs @techsio/ui-kit Label for form-control labels with valid size, disabled, required, and htmlFor usage. metadata: component_version: "1.3.0" type: "core" library: "@techsio/ui-kit" library_version: "0.3.2" requires: "component-usage-ux app-token-overrides ux-guidelines" resources: "references/ux.md ../../references/component-contracts.md ../../references/consumer_app_usage_rules.md" sources: "" contributor_sources: "libs/ui/src/atoms/label.tsx libs/ui/src/tokens/components/atoms/_label.css libs/ui/src/atoms/label.figma.ts" audience: "consumer" --- > Portable scope: Use the installed package's exported types and bundled sibling skills. Repository source paths are optional contributor evidence, not consumer prerequisites; use the consuming app's own checks. Resolve ../../references/ paths from this skill's folder, not the app working directory. # @techsio/ui-kit Label Usage Use Label for standalone form-control labels. Prefer form molecules when the whole field structure is available. ## UX/UI guidelines House rules come from the `ux-guidelines` skill (writing, formatting, states, where actions and feedback live). This section applies them to `Label`. **Use it when** - Standalone labels for controls that are not wrapped by a Form* molecule. **Use something else when** | Need | Use instead | | --- | --- | | A complete field | FormInput / FormTextarea / FormNumericInput / FormCheckbox | | Section headings | a heading element | **Do** - Connect every label to its control (`htmlFor`). - Keep labels short nouns; move explanations to help text. - Keep labels visible — no placeholder-only fields. **Don't** - End labels with a colon. - Write labels as instructions (`Please enter your email`). **Copy and states** - Sentence case, no punctuation; units in parentheses (`Weight (kg)`). **Behaviour (from the UX spec)** - Disabled styling matches a control that is really unavailable; it never makes a saved value hard to read. - The label names the value (`Supplier`), not an example of it; two neighbouring fields never share a generic label. **Figma → code** | Figma | Code | | --- | --- | | `size=current` | `size="current"` (code default; inherits text size — the Figma md preview is not its real size) | | `size=sm…lg`, `disabled`, `required` | same prop names | Full UX page (anatomy, states, behaviour, edge cases): [references/ux.md](references/ux.md). The same page renders in Storybook as *Atoms/Label → UX guidelines*. ## Setup ```tsx import { Label } from "@techsio/ui-kit/atoms/label" ``` Supported props: ```text size: sm | md | lg | current disabled: boolean required: boolean requiredLabel: string — screen-reader text after the required marker. Default "(required)"; pass a translation; "" omits it. htmlFor: native label target ``` ## Core Patterns ### Pair Label with the control id ```tsx ``` Use `htmlFor` unless the control is explicitly nested. ### Use required prop for required marker ```tsx ``` Do not manually add a red star. ### Keep size aligned with the field ```tsx ``` Use `size="current"` only inside components that inherit text sizing. ## Common Mistakes ### HIGH Native label with hardcoded styling Wrong: ```tsx ``` Correct: ```tsx ``` Source: libs/ui/src/atoms/label.tsx ### HIGH Manual required marker Wrong: ```tsx ``` Correct: ```tsx ``` Source: libs/ui/src/tokens/components/atoms/_label.css ### MEDIUM Missing association Wrong: ```tsx ``` Correct: ```tsx ``` ### MEDIUM Field built manually when molecule exists Wrong: ```tsx ``` Correct when helper/error/layout is part of the field: ```tsx ``` ## Validation Commands ```sh rg -n "]*className=.*(text-|font-|mb-|gap-)" apps rg -P -n "]*htmlFor=)" apps rg -n "]*>\\*|text-red-500.*\\*" apps rg -U -n "