BrickclayDesign System

Input

A single-line text field with label, hint, sizes and error state.

bk-inputForms and inputsAngular

Preview

A working preview of Input in the Brickclay style. Try it.

Enter a valid email address
Interact with the preview to see events here.

Interactive playground

Event log

Type, focus, blur, click the icon, or clear the field to see emitted events.

Markup

<bk-input
  [id]="'playground-input'"
  [name]="'playground-input'"
  [type]="'search'"
  label="Search"
  placeholder="Search here..."
  [iconSrc]="'assets/icons/search-input.svg'"
  [iconOrientation]="'left'"
  [clearable]="true"
  [(ngModel)]="value">
</bk-input>

Examples

Custom country list

Pass [countryOptions] to map your own countries into the phone selector. When omitted, the built-in default list is shown. You can also spread DEFAULT_COUNTRY_OPTIONS to extend the defaults instead of replacing them.

Dropdown shows GB, PK, AE, IN, your own mapped list.

Built-in defaults plus GB and PK appended.

No [countryOptions] passed, shows the built-in default list.

Trim whitespace

With [trim]="true" the emitted / form-control value has leading and trailing whitespace removed as you type, while spaces inside the value are kept. The visible text is tidied on blur (so you can still type a space between two words), and values assigned programmatically are trimmed too. Try typing " John Doe " in both fields, then click away.

trim off (default)

trim on (reactive, required)

Works with reactive and template-driven forms

clearable, like every other input/output, runs through the same ControlValueAccessor (writeValue / registerOnChange) whether the field is bound via [(ngModel)] or a reactive FormControl; there's no separate code path for either. Clear either field below to see its own form state update.

Template-driven ([(ngModel)])

Reactive (formControlName)

API reference

Inputs <bk-input>

NameTypeDefaultPossible valuesDescription
ngModelstring''any textBound via ControlValueAccessor, works with ngModel or formControlName.
id / namestring–any stringNative id/name attributes. Required for the label's for to work.
typeBkInputType'text''text' | 'email' | 'password' | 'number' | 'url' | 'tel' | 'search'Native input type. password and url also switch on the toggle icon / https prefix below; search is required for clearable to render.
sizeBkInputSize'default''default' | 'sm'Compact height/padding/font, for tight contexts like a dropdown search box.
labelstring''any textLabel above the field. Omit to render without one.
placeholderstring''any textNative placeholder. Overridden by the phone country's own placeholder when phone is on.
hintstring''any textHelper text under the field. Hidden while hasError is true.
requiredbooleanfalsetrue | falseShows a required marker (*) next to the label.
disabledbooleanfalsetrue | falseDisables the field. Also settable via setDisabledState from a reactive form.
readOnlybooleanfalsetrue | falseNative read-only, value can't be edited but is still selectable/submittable.
hasErrorbooleanfalsetrue | falseSwitches the field to its error styling and shows errorMessage instead of hint.
errorMessagestring''any textText shown under the field when hasError is true.
showErrorIconbooleanfalsetrue | falseShows an info icon on the right when hasError is true.
iconSrcstring–any icon pathIcon inside the field. Position controlled by iconOrientation; clicking it emits clicked.
iconOrientationIconOrientation'left''left' | 'right'Side iconSrc renders on.
showIconbooleantruetrue | falseToggles iconSrc visibility without removing the input.
clearablebooleanfalsetrue | falseShows a clear ("x") button once the field has a value, only applies when type="search". Renders on the side opposite iconSrc (or on the right when there's no icon), so it works with either iconOrientation. Ignored while phone, currency, or password is on, those already use both sides of the field.
trimbooleanfalsetrue | falseRemoves leading/trailing whitespace from the emitted/form value as the user types (internal spaces are kept). The visible text is trimmed on blur/change; programmatic values (writeValue, ngModel, FormControl.setValue) are trimmed too, so validators see the trimmed text.
maskstring | nullnullngx-mask pattern, e.g. '0000 0000 0000 0000'Applies an input mask (card numbers, CNIC, phone, etc). Ignored while phone is on, that uses the selected country's mask.
dropSpecialCharactersboolean | string[] | false | truefalsearray of charactersStrips mask literals (spaces, dashes, ...) from the model value, keeping only the digits/letters typed.
passwordbooleanfalsetrue | falseAdds a show/hide eye toggle and forces type to password/text accordingly.
showPasswordbooleanfalsetrue | falseInitial reveal state for a password field.
phonebooleanfalsetrue | falseAdds a country selector with per-country mask/prefix/placeholder, driven by countryCode and countryOptions.
countryCodestring'US'a code from countryOptionsSelected country when phone is on.
countryOptionsCountryOption[]US, MT, PL, CH, TR, UG, ZMarray of { code, name, mask, prefix, placeholder }Countries listed in the phone dropdown. Provide your own list to replace the defaults; when omitted (or empty) the built-in DEFAULT_COUNTRY_OPTIONS are used. Spread DEFAULT_COUNTRY_OPTIONS to extend rather than replace.
currencybooleanfalsetrue | falseFormats the value as currency while typing (e.g. 1,000,000.00) and shows a bordered dollar icon on the left, like the url prefix. Model value is a plain number (or null when empty); the display stays formatted. Ignored while mask or phone is set.
currencyDecimalsnumber2any non-negative integerNumber of decimal (cents) places shown/enforced when currency is on.
allowNegativebooleanfalsetrue | falseAllows a leading - for negative amounts when currency is on.
patternstring | null–any regex sourceNative pattern attribute for browser/form validation.
min / max / stepnumber | nullnullany numberNative numeric constraints, used with type="number".
minlength / maxlengthnumber | nullnullany numberNative text length constraints.
autoCompleteBkInputAutoComplete'off'any native autocomplete tokenNative autocomplete attribute.
autoCapitalizeBkInputAutoCompletenullnull | 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters'Native autocapitalize attribute (mobile keyboards).
inputModeBkInputModenullnull | 'text' | 'numeric' | 'decimal' | 'tel' | 'search'... | Native inputmode attribute, picks the right mobile keyboard.
tabIndexnumber | nullnullany numberNative tabindex attribute.

Outputs <bk-input>

NamePayloadFires when
inputEventRaw native input event, on every keystroke. Use ngModelChange for the parsed value.
changeEventRaw native change event, on commit (blur or Enter).
focusEventThe field gains focus.
blurEventThe field loses focus.
clickedbooleanThe iconSrc icon is clicked (no-op while disabled/readOnly).
clearedvoidThe clear ("x") button is clicked. The model is already reset to '' by then, ngModel/ngModelChange picks that up on its own; this is for side effects (e.g. re-running a search).