fix(FieldLabel): remove the gap between label and description - #5673
fix(FieldLabel): remove the gap between label and description#5673ernestt wants to merge 2 commits into
Conversation
A label and its description are one block of text, but FieldLabel returned a fragment, so the two were bare siblings of whatever column happened to hold them and their spacing came from that parent's `gap` — the same declaration that separates the label group from the control below it. No caller could space the pair independently of everything else it held, and each picked its own value: Field 4px, CheckboxInput and Switch 2px. Give the pair a wrapper of their own so the space between them is theirs to set. Measured in Chromium as `description.top - label.bottom`, the label to description gap goes 4px to 0 for Field and TextInput and 2px to 0 for CheckboxInput and Switch, while the description to control gap stays at 4px. The 2px label wrappers in CheckboxInput and Switch are now redundant and go. A hidden label group takes `display: contents`, so the wrapper box leaves the caller's layout entirely and the sr-only label and description stay out of flow exactly as they were — a hidden label still costs no space and draws no gap. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: Cursor <cursoragent@cursor.com>
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsCheckboxInput (@astryxdesign/core) · View in Storybook
Field (@astryxdesign/core) · View in Storybook
Switch (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression4 of 686 shot(s) changed. View the report To accept these exact frames: A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
|
/accept-visual 33221383949/1 All four changed frames are the same story (Field Status Variants) in four themes, and the diff is pure vertical translation: each description moves up 4px to sit flush under its label, so the three stacked fields shift 4px, 8px and 12px. No colour, border, size or text changed, and the description to input gap stays 4px. |
|
Visual changes accepted for |
xinzi-bot
left a comment
There was a problem hiding this comment.
Automated review found no blockers at the current head. FieldLabel now owns label-description spacing while preserving the control gap; exact-head tests, accessibility/RTL checks, and accepted visual evidence are green.
[Automated review]









Summary
A field's label and its description now sit flush against each other, with no gap between them.
FieldLabelreturned a fragment, so the<label>and the description<span>came out as bare siblings of whatever column happened to hold them. The space between them was therefore set by that parent'sgap— the same declaration that separates the label group from the control below it. No caller could close the pair without also pulling the control up against the description, and each had picked its own value:Field4px,CheckboxInputandSwitch2px.The pair now shares a wrapper of its own, so the space between them is theirs to set. This is one change in
FieldLabel, not a change across ~20 input components — every input reaches it throughField.Why
Requested against this reference, where the label and description read as a single block:
Before / after
Measured in Chromium as
description.top - label.bottom:TextInputFieldCheckboxInputSwitchOnly the label/description pair closes up. The description → control gap is unchanged at 4px, so fields keep their existing rhythm.
Implementation notes
gap.Field's 4pxcontainerGapis untouched — it now spaces the label group from the control instead of also splitting the label from its description.CheckboxInputandSwitcheach carried their own 2px label wrapper to do this job locally. The shared wrapper makes those redundant, so both are removed and all three callers now agree.display: contents, so the wrapper box leaves the caller's layout entirely and the sr-only label and description stay out of flow exactly as before — a hidden label still costs no space and draws no gap. The description keeps its ownsrOnlyclass.Test plan
vitestoverField/,CheckboxInput/,Switch/— 5 files, 156 tests pass (coversisLabelHidden, group labels, description click-forwarding,aria-describedbywiring).WithDescriptionstories for Field, TextInput, CheckboxInput, Switch.Screenshots are hosted on the throwaway branch
assets/core-field-label-description-gapto keep this PR's diff code-only. Safe to delete once merged.Made with Cursor