Skip to content

Commit 431e822

Browse files
lindsaym-faLeaVerou
authored andcommitted
Initial floating label attempt
1 parent df51149 commit 431e822

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/styles/themes/matter/overrides.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
.wa-text-field {
6262
--wa-form-control-value-line-height: var(--wa-line-height-normal);
6363

64+
/* Needed for floating label */
65+
position: relative;
66+
6467
&:is([appearance~='filled'], .wa-filled):not([appearance~='outlined'], .wa-outlined, [pill], .wa-pill) {
6568
--wa-focus-ring: ;
6669
--border-color: transparent transparent var(--wa-form-control-border-color) transparent;
@@ -77,6 +80,39 @@
7780
border-radius: var(--wa-form-control-border-radius) var(--wa-form-control-border-radius) 0px 0px;
7881
}
7982
}
83+
84+
/* Floating label */
85+
&::part(label) {
86+
transition: all var(--wa-transition-normal);
87+
88+
position: absolute;
89+
top: calc(var(--wa-form-control-height) / 2 - 0.5lh);
90+
left: calc(var(--wa-space) - 0.25em);
91+
z-index: 1;
92+
93+
background-color: var(--wa-form-control-background-color);
94+
padding-inline: 0.25em;
95+
}
96+
&:focus::part(label) {
97+
top: -0.5lh;
98+
color: var(--wa-color-focus);
99+
font-size: var(--wa-size-smaller);
100+
}
101+
102+
/* Different positioning and appearance for filled */
103+
&:is([appearance~='filled'], .wa-filled) {
104+
&::part(input) {
105+
padding-block: calc(var(--wa-space) * 1.5) calc(var(--wa-space) * 0.5);
106+
}
107+
108+
&::part(label) {
109+
background-color: var(--background-color);
110+
}
111+
112+
&:focus::part(label) {
113+
top: 0;
114+
}
115+
}
80116
}
81117

82118
wa-menu-item,

0 commit comments

Comments
 (0)