Skip to content

Commit 5dce436

Browse files
ShGKmebackportbot[bot]
authored andcommitted
fix(NcFormGroup): remove margin when no label/description
Signed-off-by: Grigorii K. Shartsev <me@shgk.me> [skip ci]
1 parent 68e8736 commit 5dce436

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/components/NcFormGroup/NcFormGroup.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ const props = withDefaults(defineProps<{
3939
const slots = useSlots()
4040
4141
const id = `nc-form-group-${createElementId()}`
42-
const labelId = `${id}-label`
4342
const descriptionId = `${id}-description`
4443
4544
const hasDescription = () => !!props.description || !!slots.description
4645
const getDescriptionId = () => hasDescription() ? descriptionId : undefined
46+
const hasContentOnly = () => hideLabel && (!hasDescription() || hideDescription)
4747
</script>
4848

4949
<template>
@@ -95,8 +95,7 @@ const getDescriptionId = () => hasDescription() ? descriptionId : undefined
9595
flex-direction: column;
9696
gap: var(--form-group-content-gap);
9797
margin-block-start: calc(4 * var(--default-grid-baseline));
98-
99-
&:first-child {
98+
&.formGroup__content_only {
10099
margin-block-start: 0;
101100
}
102101
}
@@ -126,4 +125,22 @@ Labelled group of form elements.
126125
</NcFormGroup>
127126
</template>
128127
```
128+
129+
### Hidden label/description
130+
131+
You can visually hide the label and/or the description.\
132+
Note: you still must provide the label. Do not visually hide the missing label warning!
133+
134+
```vue
135+
<template>
136+
<NcFormGroup
137+
label="Personal information"
138+
description="Your contact details"
139+
hide-label
140+
hide-description>
141+
<NcTextField label="First name" />
142+
<NcTextField label="Last name" />
143+
</NcFormGroup>
144+
</template>
145+
```
129146
</docs>

0 commit comments

Comments
 (0)