Skip to content

Commit 2ed6335

Browse files
authored
Merge pull request #48 from Yohn/textarea-floating-labels
Textarea floating labels
2 parents b4e4b87 + 6054ddc commit 2ed6335

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

scss/forms/_floating.scss

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@use "../settings" as *;
33

44
@if map.get($modules, "forms/floating") {
5-
// and $enable-classes {
5+
66
$transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
77

88
#{$parent-selector} section[role="form"] {
@@ -33,17 +33,6 @@
3333
transition: 0.3s ease;
3434
}
3535

36-
// Used this before I tried: >select:has(option:checked:not([disabled]))+label
37-
//> select + label {
38-
// position: absolute;
39-
// top: -5%;
40-
// left: 0.8rem;
41-
// padding: calc(var(--pico-spacing) * 0.25) calc(var(--pico-spacing) * 0.5);
42-
// transform: translateY(-50%) scale(0.85);
43-
// background: var(#{$css-var-prefix}form-element-background-color);
44-
// cursor: text;
45-
//}
46-
4736
> input:not(:placeholder-shown) + label,
4837
> input:focus + label,
4938
> textarea:not(:placeholder-shown) + label,
@@ -60,6 +49,16 @@
6049
transition: all $transition-fast;
6150
}
6251

52+
> textarea + label {
53+
top: 1rem;
54+
transform: translateY(0);
55+
}
56+
> textarea:not(:placeholder-shown) + label,
57+
> textarea:focus + label {
58+
top: 0;
59+
transform: translateY(-50%) scale(0.8);
60+
}
61+
6362
@if map.get($modules, "forms/validation") {
6463
> input:user-invalid:not(:placeholder-shown) + label,
6564
> textarea:user-invalid:not(:placeholder-shown) + label {

0 commit comments

Comments
 (0)