Skip to content

Commit 3aabfc7

Browse files
mdoXhmikosR
andauthored
Another pass at fixing floating labels disabled colors (#38313)
* Another pass at fixing floating labels disabled colors * Fix height for textareas * Fix disabled background * Move from full width to an inline-block-ish approach --------- Co-authored-by: XhmikosR <[email protected]>
1 parent 7a7fc1a commit 3aabfc7

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

scss/_variables.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ $form-floating-padding-x: $input-padding-x !default;
10681068
$form-floating-padding-y: 1rem !default;
10691069
$form-floating-input-padding-t: 1.625rem !default;
10701070
$form-floating-input-padding-b: .625rem !default;
1071-
$form-floating-label-height: 1.875em !default;
1071+
$form-floating-label-height: 1.5em !default;
10721072
$form-floating-label-opacity: .65 !default;
10731073
$form-floating-label-transform: scale(.85) translateY(-.5rem) translateX(.15rem) !default;
10741074
$form-floating-label-disabled-color: $gray-600 !default;

scss/forms/_floating-labels.scss

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
.form-floating {
22
position: relative;
33

4-
&:not(.form-control:disabled)::before {
5-
position: absolute;
6-
top: $input-border-width;
7-
left: $input-border-width;
8-
width: subtract(100%, add($input-height-inner-quarter, $input-height-inner-half));
9-
height: $form-floating-label-height;
10-
content: "";
11-
background-color: $input-bg;
12-
@include border-radius($input-border-radius);
13-
}
14-
154
> .form-control,
165
> .form-control-plaintext,
176
> .form-select {
@@ -23,7 +12,7 @@
2312
position: absolute;
2413
top: 0;
2514
left: 0;
26-
width: 100%;
15+
z-index: 2;
2716
height: 100%; // allow textareas
2817
padding: $form-floating-padding-y $form-floating-padding-x;
2918
overflow: hidden;
@@ -66,14 +55,24 @@
6655
> .form-control-plaintext,
6756
> .form-select {
6857
~ label {
69-
opacity: $form-floating-label-opacity;
58+
color: rgba(var(--#{$prefix}body-color-rgb), #{$form-floating-label-opacity});
7059
transform: $form-floating-label-transform;
60+
61+
&::after {
62+
position: absolute;
63+
inset: $form-floating-padding-y ($form-floating-padding-x * .5);
64+
z-index: -1;
65+
height: $form-floating-label-height;
66+
content: "";
67+
background-color: $input-bg;
68+
@include border-radius($input-border-radius);
69+
}
7170
}
7271
}
7372
// Duplicated because `:-webkit-autofill` invalidates other selectors when grouped
7473
> .form-control:-webkit-autofill {
7574
~ label {
76-
opacity: $form-floating-label-opacity;
75+
color: rgba(var(--#{$prefix}body-color-rgb), #{$form-floating-label-opacity});
7776
transform: $form-floating-label-transform;
7877
}
7978
}
@@ -84,7 +83,11 @@
8483
}
8584
}
8685

87-
> .form-control:disabled ~ label {
86+
> :disabled ~ label {
8887
color: $form-floating-label-disabled-color;
88+
89+
&::after {
90+
background-color: $input-disabled-bg;
91+
}
8992
}
9093
}

0 commit comments

Comments
 (0)