UNPKG

carbon-components-angular

Version:
1,314 lines (1,180 loc) 75.4 kB
<!doctype html> <html class="no-js" lang=""> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>carbon-components-angular documentation</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="../images/favicon.ico"> <link rel="stylesheet" href="../styles/style.css"> <link rel="stylesheet" href="../styles/dark.css"> <style> footer.carbon { position: absolute; bottom: 0; width: 100%; z-index: 9999; } #root > div { /* * Subtracting the height of the footer to prevent * overlaying the footer ontop of content */ height: calc(100vh - 48px); } </style> </head> <body> <script> // Blocking script to avoid flickering dark mode // Dark mode toggle button var useDark = window.matchMedia('(prefers-color-scheme: dark)'); var darkModeState = useDark.matches; var $darkModeToggleSwitchers = document.querySelectorAll('.dark-mode-switch input'); var $darkModeToggles = document.querySelectorAll('.dark-mode-switch'); var darkModeStateLocal = localStorage.getItem('compodoc_darkmode-state'); function checkToggle(check) { for (var i = 0; i < $darkModeToggleSwitchers.length; i++) { $darkModeToggleSwitchers[i].checked = check; } } function toggleDarkMode(state) { if (window.localStorage) { localStorage.setItem('compodoc_darkmode-state', state); } checkToggle(state); const hasClass = document.body.classList.contains('dark'); if (state) { for (var i = 0; i < $darkModeToggles.length; i++) { $darkModeToggles[i].classList.add('dark'); } if (!hasClass) { document.body.classList.add('dark'); } } else { for (var i = 0; i < $darkModeToggles.length; i++) { $darkModeToggles[i].classList.remove('dark'); } if (hasClass) { document.body.classList.remove('dark'); } } } useDark.addEventListener('change', function (evt) { toggleDarkMode(evt.matches); }); if (darkModeStateLocal) { darkModeState = darkModeStateLocal === 'true'; } toggleDarkMode(darkModeState); </script> <div class="navbar navbar-default navbar-fixed-top d-md-none p-0"> <div class="d-flex"> <a href="../" class="navbar-brand">carbon-components-angular documentation</a> <button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button> </div> </div> <div class="xs-menu menu" id="mobile-menu"> <div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu> </div> <div class="container-fluid main"> <div class="row main"> <div class="d-none d-md-block menu"> <compodoc-menu mode="normal"></compodoc-menu> </div> <!-- START CONTENT --> <div class="content component"> <div class="content-data"> <ol class="breadcrumb"> <li class="breadcrumb-item">Components</li> <li class="breadcrumb-item" > Label</li> </ol> <ul class="nav nav-tabs" role="tablist"> <li class="nav-item"> <a href="#info" class="nav-link active" role="tab" id="info-tab" data-bs-toggle="tab" data-link="info">Info</a> </li> <li class="nav-item"> <a href="#source" class="nav-link" role="tab" id="source-tab" data-bs-toggle="tab" data-link="source">Source</a> </li> <li class="nav-item"> <a href="#tree" class="nav-link" role="tab" id="tree-tab" data-bs-toggle="tab" data-link="dom-tree">DOM Tree</a> </li> </ul> <div class="tab-content"> <div class="tab-pane fade active in" id="info"><p class="comment"> <h3>File</h3> </p> <p class="comment"> <code>src/input/label.component.ts</code> </p> <p class="comment"> <h3>Description</h3> </p> <p class="comment"> <p>Get started with importing the module:</p> <b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">import { InputModule } from &#39;carbon-components-angular&#39;;</code></pre></div><p>To prevent attribute drilling, use <code>ibm-text-label</code> or <code>ibm-textarea-label</code> components</p> <b>Example :</b><div><pre class="line-numbers"><code class="language-html">&lt;cds-label&gt; Label &lt;input cdsText type=&quot;text&quot; class=&quot;input-field&quot;&gt; &lt;/cds-label&gt;</code></pre></div><p><a href="../../?path=/story/components-input--basic">See demo</a></p> </p> <p class="comment"> <h3>Implements</h3> </p> <p class="comment"> <code>AfterContentInit</code> <code>AfterViewInit</code> </p> <section data-compodoc="block-metadata"> <h3>Metadata</h3> <table class="table table-sm table-hover metadata"> <tbody> <tr> <td class="col-md-3">selector</td> <td class="col-md-9"><code>cds-label, ibm-label</code></td> </tr> <tr> <td class="col-md-3">template</td> <td class="col-md-9"><pre class="line-numbers"><code class="language-html">&lt;ng-template #inputContentTemplate&gt; &lt;ng-content select&#x3D;&quot;input,textarea,div&quot;&gt;&lt;/ng-content&gt; &lt;/ng-template&gt; &lt;ng-template #labelContentTemplate&gt; &lt;ng-content&gt;&lt;/ng-content&gt; &lt;/ng-template&gt; &lt;ng-container [ngSwitch]&#x3D;&quot;type&quot;&gt; &lt;ng-container *ngSwitchCase&#x3D;&quot;&#x27;TextArea&#x27;&quot;&gt; &lt;cds-textarea-label [labelInputID]&#x3D;&quot;labelInputID&quot; [disabled]&#x3D;&quot;disabled&quot; [skeleton]&#x3D;&quot;skeleton&quot; [helperText]&#x3D;&quot;helperText&quot; [invalid]&#x3D;&quot;invalid&quot; [invalidText]&#x3D;&quot;invalidText&quot; [warn]&#x3D;&quot;warn&quot; [warnText]&#x3D;&quot;warnText&quot; [ariaLabel]&#x3D;&quot;ariaLabel&quot; [labelTemplate]&#x3D;&quot;labelContentTemplate&quot; [textAreaTemplate]&#x3D;&quot;inputContentTemplate&quot;&gt; &lt;/cds-textarea-label&gt; &lt;/ng-container&gt; &lt;ng-container *ngSwitchCase&#x3D;&quot;&#x27;TextInput&#x27;&quot;&gt; &lt;cds-text-label [labelInputID]&#x3D;&quot;labelInputID&quot; [disabled]&#x3D;&quot;disabled&quot; [skeleton]&#x3D;&quot;skeleton&quot; [helperText]&#x3D;&quot;helperText&quot; [invalid]&#x3D;&quot;invalid&quot; [invalidText]&#x3D;&quot;invalidText&quot; [warn]&#x3D;&quot;warn&quot; [warnText]&#x3D;&quot;warnText&quot; [ariaLabel]&#x3D;&quot;ariaLabel&quot; [labelTemplate]&#x3D;&quot;labelContentTemplate&quot; [textInputTemplate]&#x3D;&quot;inputContentTemplate&quot;&gt; &lt;/cds-text-label&gt; &lt;/ng-container&gt; &lt;ng-container *ngSwitchCase&#x3D;&quot;&#x27;PasswordInput&#x27;&quot;&gt; &lt;cds-password-label [labelInputID]&#x3D;&quot;labelInputID&quot; [disabled]&#x3D;&quot;disabled&quot; [skeleton]&#x3D;&quot;skeleton&quot; [helperText]&#x3D;&quot;helperText&quot; [invalid]&#x3D;&quot;invalid&quot; [invalidText]&#x3D;&quot;invalidText&quot; [warn]&#x3D;&quot;warn&quot; [warnText]&#x3D;&quot;warnText&quot; [ariaLabel]&#x3D;&quot;ariaLabel&quot; [labelTemplate]&#x3D;&quot;labelContentTemplate&quot; [passwordInputTemplate]&#x3D;&quot;inputContentTemplate&quot;&gt; &lt;/cds-password-label&gt; &lt;/ng-container&gt; &lt;ng-container *ngSwitchDefault&gt; &lt;ng-template [ngTemplateOutlet]&#x3D;&quot;default&quot;&gt;&lt;/ng-template&gt; &lt;/ng-container&gt; &lt;/ng-container&gt; &lt;ng-template #default&gt; &lt;label [for]&#x3D;&quot;labelInputID&quot; [attr.aria-label]&#x3D;&quot;ariaLabel&quot; class&#x3D;&quot;cds--label&quot; [ngClass]&#x3D;&quot;{ &#x27;cds--label--disabled&#x27;: disabled, &#x27;cds--skeleton&#x27;: skeleton }&quot;&gt; &lt;ng-template [ngTemplateOutlet]&#x3D;&quot;labelContentTemplate&quot;&gt;&lt;/ng-template&gt; &lt;/label&gt; &lt;div class&#x3D;&quot;cds--text-input__field-wrapper&quot; [ngClass]&#x3D;&quot;{ &#x27;cds--text-input__field-wrapper--warning&#x27;: warn }&quot; [attr.data-invalid]&#x3D;&quot;(invalid ? true : null)&quot; #wrapper&gt; &lt;svg *ngIf&#x3D;&quot;invalid&quot; cdsIcon&#x3D;&quot;warning--filled&quot; size&#x3D;&quot;16&quot; class&#x3D;&quot;cds--text-input__invalid-icon&quot;&gt; &lt;/svg&gt; &lt;svg *ngIf&#x3D;&quot;!invalid &amp;&amp; warn&quot; cdsIcon&#x3D;&quot;warning--alt--filled&quot; size&#x3D;&quot;16&quot; class&#x3D;&quot;cds--text-input__invalid-icon cds--text-input__invalid-icon--warning&quot;&gt; &lt;/svg&gt; &lt;ng-template [ngTemplateOutlet]&#x3D;&quot;inputContentTemplate&quot;&gt;&lt;/ng-template&gt; &lt;/div&gt; &lt;div *ngIf&#x3D;&quot;!skeleton &amp;&amp; helperText &amp;&amp; !invalid &amp;&amp; !warn&quot; class&#x3D;&quot;cds--form__helper-text&quot; [ngClass]&#x3D;&quot;{&#x27;cds--form__helper-text--disabled&#x27;: disabled}&quot;&gt; &lt;ng-container *ngIf&#x3D;&quot;!isTemplate(helperText)&quot;&gt;{{helperText}}&lt;/ng-container&gt; &lt;ng-template *ngIf&#x3D;&quot;isTemplate(helperText)&quot; [ngTemplateOutlet]&#x3D;&quot;helperText&quot;&gt;&lt;/ng-template&gt; &lt;/div&gt; &lt;div *ngIf&#x3D;&quot;invalid&quot; class&#x3D;&quot;cds--form-requirement&quot;&gt; &lt;ng-container *ngIf&#x3D;&quot;!isTemplate(invalidText)&quot;&gt;{{invalidText}}&lt;/ng-container&gt; &lt;ng-template *ngIf&#x3D;&quot;isTemplate(invalidText)&quot; [ngTemplateOutlet]&#x3D;&quot;invalidText&quot;&gt;&lt;/ng-template&gt; &lt;/div&gt; &lt;div *ngIf&#x3D;&quot;!invalid &amp;&amp; warn&quot; class&#x3D;&quot;cds--form-requirement&quot;&gt; &lt;ng-container *ngIf&#x3D;&quot;!isTemplate(warnText)&quot;&gt;{{warnText}}&lt;/ng-container&gt; &lt;ng-template *ngIf&#x3D;&quot;isTemplate(warnText)&quot; [ngTemplateOutlet]&#x3D;&quot;warnText&quot;&gt;&lt;/ng-template&gt; &lt;/div&gt; &lt;/ng-template&gt; </code></pre></td> </tr> </tbody> </table> </section> <section data-compodoc="block-index"> <h3 id="index">Index</h3> <table class="table table-sm table-bordered index-table"> <tbody> <tr> <td class="col-md-4"> <h6><b>Properties</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <span class="modifier">Static</span> <a href="#labelCounter" >labelCounter</a> </li> <li> <span class="modifier"></span> <a href="#passwordInput" >passwordInput</a> </li> <li> <span class="modifier"></span> <a href="#textArea" >textArea</a> </li> <li> <span class="modifier"></span> <a href="#textInput" >textInput</a> </li> <li> <a href="#type" >type</a> </li> <li> <span class="modifier"></span> <a href="#wrapper" >wrapper</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>Methods</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <span class="modifier">Public</span> <a href="#isTemplate" >isTemplate</a> </li> <li> <a href="#ngAfterContentInit" >ngAfterContentInit</a> </li> <li> <a href="#ngAfterViewInit" >ngAfterViewInit</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>Inputs</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <a href="#ariaLabel" >ariaLabel</a> </li> <li> <a href="#disabled" >disabled</a> </li> <li> <a href="#helperText" >helperText</a> </li> <li> <a href="#invalid" >invalid</a> </li> <li> <a href="#invalidText" >invalidText</a> </li> <li> <a href="#labelInputID" >labelInputID</a> </li> <li> <a href="#skeleton" >skeleton</a> </li> <li> <a href="#warn" >warn</a> </li> <li> <a href="#warnText" >warnText</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>HostBindings</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <a href="#class.cds--form-item" >class.cds--form-item</a> </li> </ul> </td> </tr> <tr> <td class="col-md-4"> <h6><b>Accessors</b></h6> </td> </tr> <tr> <td class="col-md-4"> <ul class="index-list"> <li> <a href="#labelClass" >labelClass</a> </li> </ul> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-constructor"> <h3 id="constructor">Constructor</h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <code>constructor(changeDetectorRef: ChangeDetectorRef)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="205" class="link-to-prism">src/input/label.component.ts:205</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Creates an instance of Label.</p> </div> <div> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Type</td> <td>Optional</td> </tr> </thead> <tbody> <tr> <td>changeDetectorRef</td> <td> <code>ChangeDetectorRef</code> </td> <td> No </td> </tr> </tbody> </table> </div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-inputs"> <h3 id="inputs">Inputs</h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="ariaLabel"></a> <b>ariaLabel</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="189" class="link-to-prism">src/input/label.component.ts:189</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Set the arialabel for label</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="disabled"></a> <b>disabled</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>false</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="161" class="link-to-prism">src/input/label.component.ts:161</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Set to <code>true</code> for disabled state.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="helperText"></a> <b>helperText</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code>string | TemplateRef&lt;any&gt;</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="169" class="link-to-prism">src/input/label.component.ts:169</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Optional helper text that appears under the label.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="invalid"></a> <b>invalid</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>false</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="177" class="link-to-prism">src/input/label.component.ts:177</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Set to <code>true</code> for an invalid label component.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="invalidText"></a> <b>invalidText</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code>string | TemplateRef&lt;any&gt;</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="173" class="link-to-prism">src/input/label.component.ts:173</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Sets the invalid text.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="labelInputID"></a> <b>labelInputID</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>&#x60;cds-label-${Label.labelCounter++}&#x60;</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="157" class="link-to-prism">src/input/label.component.ts:157</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>The id of the input item associated with the <code>Label</code>. This value is also used to associate the <code>Label</code> with its input counterpart through the &#39;for&#39; attribute.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="skeleton"></a> <b>skeleton</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>false</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="165" class="link-to-prism">src/input/label.component.ts:165</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Set to <code>true</code> for a loading label.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="warn"></a> <b>warn</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>false</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="181" class="link-to-prism">src/input/label.component.ts:181</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Set to <code>true</code> to show a warning (contents set by warningText)</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="warnText"></a> <b>warnText</b> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code>string | TemplateRef&lt;any&gt;</code> </td> </tr> <tr> <td class="col-md-2" colspan="2"> <div class="io-line">Defined in <a href="" data-line="185" class="link-to-prism">src/input/label.component.ts:185</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Sets the warning text</p> </div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-properties"> <h3>HostBindings</h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="class.cds--form-item"></a> <span class="name"> <span ><b>class.cds--form-item</b></span> <a href="#class.cds--form-item"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="201" class="link-to-prism">src/input/label.component.ts:201</a></div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-methods"> <h3 id="methods"> Methods </h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="isTemplate"></a> <span class="name"> <span class="modifier">Public</span> <span ><b>isTemplate</b></span> <a href="#isTemplate"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <span class="modifier-icon icon ion-ios-reset"></span> <code>isTemplate(value)</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="254" class="link-to-prism">src/input/label.component.ts:254</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"> <b>Parameters :</b> <table class="params"> <thead> <tr> <td>Name</td> <td>Optional</td> </tr> </thead> <tbody> <tr> <td>value</td> <td> No </td> </tr> </tbody> </table> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code> </div> <div class="io-description"> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="ngAfterContentInit"></a> <span class="name"> <span ><b>ngAfterContentInit</b></span> <a href="#ngAfterContentInit"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>ngAfterContentInit()</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="215" class="link-to-prism">src/input/label.component.ts:215</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Update wrapper class if a textarea is hosted.</p> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="ngAfterViewInit"></a> <span class="name"> <span ><b>ngAfterViewInit</b></span> <a href="#ngAfterViewInit"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <code>ngAfterViewInit()</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="228" class="link-to-prism">src/input/label.component.ts:228</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Sets the id on the input item associated with the <code>Label</code>.</p> </div> <div class="io-description"> <b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code> </div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-properties"> <h3 id="inputs"> Properties </h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="labelCounter"></a> <span class="name"> <span class="modifier">Static</span> <span ><b>labelCounter</b></span> <a href="#labelCounter"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code> </td> </tr> <tr> <td class="col-md-4"> <i>Default value : </i><code>0</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="152" class="link-to-prism">src/input/label.component.ts:152</a></div> </td> </tr> <tr> <td class="col-md-4"> <div class="io-description"><p>Used to build the id of the input item associated with the <code>Label</code>.</p> </div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="passwordInput"></a> <span class="name"> <span class="modifier"></span> <span ><b>passwordInput</b></span> <a href="#passwordInput"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="../directives/PasswordInput.html" target="_self" >PasswordInput</a></code> </td> </tr> <tr> <td class="col-md-4"> <b>Decorators : </b> <br /> <code> @ContentChild(PasswordInput, {static: false})<br /> </code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="199" class="link-to-prism">src/input/label.component.ts:199</a></div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="textArea"></a> <span class="name"> <span class="modifier"></span> <span ><b>textArea</b></span> <a href="#textArea"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="../directives/TextArea.html" target="_self" >TextArea</a></code> </td> </tr> <tr> <td class="col-md-4"> <b>Decorators : </b> <br /> <code> @ContentChild(TextArea)<br /> </code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="193" class="link-to-prism">src/input/label.component.ts:193</a></div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="textInput"></a> <span class="name"> <span class="modifier"></span> <span ><b>textInput</b></span> <a href="#textInput"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code><a href="../directives/TextInput.html" target="_self" >TextInput</a></code> </td> </tr> <tr> <td class="col-md-4"> <b>Decorators : </b> <br /> <code> @ContentChild(TextInput, {static: false})<br /> </code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="196" class="link-to-prism">src/input/label.component.ts:196</a></div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="type"></a> <span class="name"> <span ><b>type</b></span> <a href="#type"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code>&quot;TextArea&quot; | &quot;TextInput&quot; | &quot;PasswordInput&quot;</code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="205" class="link-to-prism">src/input/label.component.ts:205</a></div> </td> </tr> </tbody> </table> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="wrapper"></a> <span class="name"> <span class="modifier"></span> <span ><b>wrapper</b></span> <a href="#wrapper"><span class="icon ion-ios-link"></span></a> </span> </td> </tr> <tr> <td class="col-md-4"> <i>Type : </i> <code>ElementRef&lt;HTMLDivElement&gt;</code> </td> </tr> <tr> <td class="col-md-4"> <b>Decorators : </b> <br /> <code> @ViewChild(&#x27;wrapper&#x27;)<br /> </code> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="191" class="link-to-prism">src/input/label.component.ts:191</a></div> </td> </tr> </tbody> </table> </section> <section data-compodoc="block-accessors"> <h3 id="accessors"> Accessors </h3> <table class="table table-sm table-bordered"> <tbody> <tr> <td class="col-md-4"> <a name="labelClass"></a> <span class="name"><b>labelClass</b><a href="#labelClass"><span class="icon ion-ios-link"></span></a></span> </td> </tr> <tr> <td class="col-md-4"> <span class="accessor"><b>get</b><code>labelClass()</code></span> </td> </tr> <tr> <td class="col-md-4"> <div class="io-line">Defined in <a href="" data-line="201" class="link-to-prism">src/input/label.component.ts:201</a></div> </td> </tr> </tbody> </table> </section> </div> <div class="tab-pane fade tab-source-code" id="source"> <pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Component, Input, AfterViewInit, ElementRef, HostBinding, TemplateRef, ViewChild, ContentChild, AfterContentInit, ChangeDetectorRef } from &quot;@angular/core&quot;; import { TextArea } from &quot;./text-area.directive&quot;; import { TextInput } from &quot;./input.directive&quot;; import { PasswordInput } from &quot;./password.directive&quot;; /** * Get started with importing the module: * * &#x60;&#x60;&#x60;typescript * import { InputModule } from &#x27;carbon-components-angular&#x27;; * &#x60;&#x60;&#x60; * * To prevent attribute drilling, use &#x60;ibm-text-label&#x60; or &#x60;ibm-textarea-label&#x60; components * * &#x60;&#x60;&#x60;html * &lt;cds-label&gt; * Label * &lt;input cdsText type&#x3D;&quot;text&quot; class&#x3D;&quot;input-field&quot;&gt; * &lt;/cds-label&gt; * &#x60;&#x60;&#x60; * * [See demo](../../?path&#x3D;/story/components-input--basic) */ @Component({ selector: &quot;cds-label, ibm-label&quot;, template: &#x60; &lt;ng-template #inputContentTemplate&gt; &lt;ng-content select&#x3D;&quot;input,textarea,div&quot;&gt;&lt;/ng-content&gt; &lt;/ng-template&gt; &lt;ng-template #labelContentTemplate&gt; &lt;ng-content&gt;&lt;/ng-content&gt; &lt;/ng-template&gt; &lt;ng-container [ngSwitch]&#x3D;&quot;type&quot;&gt; &lt;ng-container *ngSwitchCase&#x3D;&quot;&#x27;TextArea&#x27;&quot;&gt; &lt;cds-textarea-label [labelInputID]&#x3D;&quot;labelInputID&quot; [disabled]&#x3D;&quot;disabled&quot; [skeleton]&#x3D;&quot;skeleton&quot; [helperText]&#x3D;&quot;helperText&quot; [invalid]&#x3D;&quot;invalid&quot; [invalidText]&#x3D;&quot;invalidText&quot; [warn]&#x3D;&quot;warn&quot; [warnText]&#x3D;&quot;warnText&quot; [ariaLabel]&#x3D;&quot;ariaLabel&quot; [labelTemplate]&#x3D;&quot;labelContentTemplate&quot; [textAreaTemplate]&#x3D;&quot;inputContentTemplate&quot;&gt; &lt;/cds-textarea-label&gt; &lt;/ng-container&gt; &lt;ng-container *ngSwitchCase&#x3D;&quot;&#x27;TextInput&#x27;&quot;&gt; &lt;cds-text-label [labelInputID]&#x3D;&quot;labelInputID&quot; [disabled]&#x3D;&quot;disabled&quot; [skeleton]&#x3D;&quot;skeleton&quot; [helperText]&#x3D;&quot;helperText&quot; [invalid]&#x3D;&quot;invalid&quot; [invalidText]&#x3D;&quot;invalidText&quot; [warn]&#x3D;&quot;warn&quot; [warnText]&#x3D;&quot;warnText&quot; [ariaLabel]&#x3D;&quot;ariaLabel&quot; [labelTemplate]&#x3D;&quot;labelContentTemplate&quot; [textInputTemplate]&#x3D;&quot;inputContentTemplate&quot;&gt; &lt;/cds-text-label&gt; &lt;/ng-container&gt; &lt;ng-container *ngSwitchCase&#x3D;&quot;&#x27;PasswordInput&#x27;&quot;&gt; &lt;cds-password-label [labelInputID]&#x3D;&quot;labelInputID&quot; [disabled]&#x3D;&quot;disabled&quot; [skeleton]&#x3D;&quot;skeleton&quot; [helperText]&#x3D;&quot;helperText&quot; [invalid]&#x3D;&quot;invalid&quot; [invalidText]&#x3D;&quot;invalidText&quot; [warn]&#x3D;&quot;warn&quot; [warnText]&#x3D;&quot;warnText&quot; [ariaLabel]&#x3D;&quot;ariaLabel&quot; [labelTemplate]&#x3D;&quot;labelContentTemplate&quot; [passwordInputTemplate]&#x3D;&quot;inputContentTemplate&quot;&gt; &lt;/cds-password-label&gt; &lt;/ng-container&gt; &lt;ng-container *ngSwitchDefault&gt; &lt;ng-template [ngTemplateOutlet]&#x3D;&quot;default&quot;&gt;&lt;/ng-template&gt; &lt;/ng-container&gt; &lt;/ng-container&gt; &lt;ng-template #default&gt; &lt;label [for]&#x3D;&quot;labelInputID&quot; [attr.aria-label]&#x3D;&quot;ariaLabel&quot; class&#x3D;&quot;cds--label&quot; [ngClass]&#x3D;&quot;{ &#x27;cds--label--disabled&#x27;: disabled, &#x27;cds--skeleton&#x27;: skeleton }&quot;&gt; &lt;ng-template [ngTemplateOutlet]&#x3D;&quot;labelContentTemplate&quot;&gt;&lt;/ng-template&gt; &lt;/label&gt; &lt;div class&#x3D;&quot;cds--text-input__field-wrapper&quot; [ngClass]&#x3D;&quot;{ &#x27;cds--text-input__field-wrapper--warning&#x27;: warn }&quot; [attr.data-invalid]&#x3D;&quot;(invalid ? true : null)&quot; #wrapper&gt; &lt;svg *ngIf&#x3D;&quot;invalid&quot; cdsIcon&#x3D;&quot;warning--filled&quot; size&#x3D;&quot;16&quot; class&#x3D;&quot;cds--text-input__invalid-icon&quot;&gt; &lt;/svg&gt; &lt;svg *ngIf&#x3D;&quot;!invalid &amp;&amp; warn&quot; cdsIcon&#x3D;&q