with one click
canopy-forms-input
// Best practices for the Canopy Text Input component. Trigger when adding text input fields, single-line form inputs, prefixes, suffixes, or input buttons in an Angular project using Canopy.
// Best practices for the Canopy Text Input component. Trigger when adding text input fields, single-line form inputs, prefixes, suffixes, or input buttons in an Angular project using Canopy.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | canopy-forms-input |
| description | Best practices for the Canopy Text Input component. Trigger when adding text input fields, single-line form inputs, prefixes, suffixes, or input buttons in an Angular project using Canopy. |
| license | MIT |
| metadata | {"source":"https://github.com/Legal-and-General/canopy/tree/master/projects/canopy/src/lib/forms/input/docs/guide.mdx"} |
This skill provides usage guidance, dos and don'ts, and input reference for the Canopy lg-input-field component from @legal-and-general/canopy.
Apply this skill whenever you use LgInputFieldComponent or the lgInput directive.
import { LgInputFieldComponent, LgInputDirective } from '@legal-and-general/canopy';
For hints and validation:
import { LgHintComponent, LgValidationComponent } from '@legal-and-general/canopy';
Use Angular reactive forms. The lgInput directive goes on the <input> element inside lg-input-field.
<lg-input-field>
Name
<lg-hint>Please enter your full name</lg-hint>
<input lgInput formControlName="name" />
</lg-input-field>
<!-- Currency prefix -->
<lg-input-field>
Amount
<input lgInput formControlName="amount" />
<span lgPrefix>Ā£</span>
</lg-input-field>
<!-- Percentage suffix -->
<lg-input-field>
Rate
<input lgInput formControlName="rate" />
<span lgSuffix>%</span>
</lg-input-field>
Use the lgSuffix directive for buttons inside the input border (add-on variant).
<!-- Icon-only add-on button -->
<lg-input-field>
Search
<input lgInput formControlName="query" />
<button lg-button lgSuffix [iconButton]="true" priority="add-on">
Clear
<lg-icon name="close"></lg-icon>
</button>
</lg-input-field>
Use the lgInputFieldExternalButton directive for buttons outside the input border (e.g., search or submit).
<lg-input-field>
Search
<input lgInput formControlName="query" />
<button lg-button lgInputFieldExternalButton priority="primary">
</button>
</lg-input-field>
You can combine multiple suffixes with an external button:
<lg-input-field>
Amount
<input lgInput formControlName="amount" />
<span lgSuffix>%</span>
<button lg-button lgSuffix [iconButton]="true" priority="add-on">
Clear
<lg-icon name="close" />
</button>
<button lg-button lgInputFieldExternalButton priority="primary">
Submit
</button>
</lg-input-field>
| Input | Type | Default | Description |
|---|---|---|---|
id | string | auto-generated | HTML id attribute. |
name | string | auto-generated | HTML name attribute. |
| Input | Type | Default | Description |
|---|---|---|---|
id | string | auto-generated | Propagates to the input id and label for. |
block | boolean | false | Makes the input full-width on small screens. |
showLabel | boolean | true | Visually shows or hides the label. |