Skip to content

Commit 52f2140

Browse files
Barsneseirikbacker
andauthored
style(Field): change style of Label (#4134)
Co-authored-by: Eirik Backer <eirik.backer@gmail.com>
1 parent afb2589 commit 52f2140

6 files changed

Lines changed: 24 additions & 1 deletion

File tree

.changeset/brown-candles-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@digdir/designsystemet-css": patch
3+
---
4+
5+
**Field**: Set `display: block` on `<label>`

.changeset/small-bikes-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@digdir/designsystemet-css": patch
3+
---
4+
5+
**Label**: Use `line-height: var(--ds-body-md-line-height);`

.changeset/soft-planes-watch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@digdir/designsystemet-css": patch
3+
---
4+
5+
**Field**: `data-field="description"` no longer gets `margin-top`

packages/css/src/field.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
color: var(
1515
--ds-color-neutral-text-subtle
1616
); /* TODO: Change to opacity or color-mix(currentColor, trasparent) to ensure contrast when parent element color changes? */
17+
margin-top: 0; /* Line-height removes the need for this */
18+
margin-block: 0;
1719
}
1820

1921
& input:not([hidden]),
@@ -23,6 +25,11 @@
2325
display: block; /* Ensure input is not placed on same line as label/description/validation */
2426
}
2527

28+
/* Respect hidden attribute and make overwrites easy */
29+
& label:where(:not([hidden])) {
30+
display: block;
31+
}
32+
2633
/**
2734
* States
2835
*/

packages/css/src/fieldset.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
& > legend + p {
2222
color: var(--ds-color-neutral-text-subtle);
23-
margin-block: var(--ds-size-1) 0;
23+
margin-block: 0;
2424
}
2525

2626
& > *.ds-sr-only + * {

packages/css/src/label.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.ds-label {
22
font-weight: var(--ds-font-weight-medium);
3+
line-height: var(--ds-body-md-line-height);
34

45
&[data-weight='semibold'] {
56
font-weight: var(--ds-font-weight-semibold);

0 commit comments

Comments
 (0)