Skip to content

Commit 9e8a31e

Browse files
authored
Merge pull request #2135 from yinglejia/label-disabled
fix(label): add support for disabled state
2 parents 44d2779 + 3fa0b4e commit 9e8a31e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/input/input.stories.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ storiesOf("Components|Input", module).addDecorator(
2020
.add("Label", () => ({
2121
template: `
2222
<ibm-label
23+
[disabled]="disabled"
2324
[helperText]="helperText"
2425
[invalid]="invalid"
2526
[invalidText]="invalidText"
@@ -54,6 +55,7 @@ storiesOf("Components|Input", module).addDecorator(
5455
.add("TextArea", () => ({
5556
template: `
5657
<ibm-label
58+
[disabled]="disabled"
5759
[helperText]="helperText"
5860
[invalid]="invalid"
5961
[invalidText]="invalidText">

src/input/label.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { TextArea } from "./text-area.directive";
4242
[attr.aria-label]="ariaLabel"
4343
class="bx--label"
4444
[ngClass]="{
45+
'bx--label--disabled': disabled,
4546
'bx--skeleton': skeleton
4647
}">
4748
<ng-content></ng-content>
@@ -70,7 +71,10 @@ import { TextArea } from "./text-area.directive";
7071
</svg>
7172
<ng-content select="input,textarea,div"></ng-content>
7273
</div>
73-
<div *ngIf="!skeleton && helperText && !invalid && !warn" class="bx--form__helper-text">
74+
<div
75+
*ngIf="!skeleton && helperText && !invalid && !warn"
76+
class="bx--form__helper-text"
77+
[ngClass]="{'bx--form__helper-text--disabled': disabled}">
7478
<ng-container *ngIf="!isTemplate(helperText)">{{helperText}}</ng-container>
7579
<ng-template *ngIf="isTemplate(helperText)" [ngTemplateOutlet]="helperText"></ng-template>
7680
</div>
@@ -103,6 +107,10 @@ export class Label implements AfterContentInit, AfterViewInit {
103107
* State of the `Label` will determine the styles applied.
104108
*/
105109
@Input() labelState: "success" | "warning" | "error" | "" = "";
110+
/**
111+
* Set to `true` for a disabled label.
112+
*/
113+
@Input() disabled = false;
106114
/**
107115
* Set to `true` for a loading label.
108116
*/

0 commit comments

Comments
 (0)