Skip to main content

BwControl | bw-control

Overview​

Use BwControl to build new form controls. The component does not do much by itself, as you have to tell it how to integrate into the form.

Usage​

Example​

Account Number
--
SubmitReset
<bw-form id="control-form">
<div class="flex-column gap-sm">
<bw-control name="accountNumber">
<bw-label>Account Number</bw-label>
<div class="flex-row gap-xs align-center" style="max-width: 300px;">
<bw-input placeholder="00" id="num-1" maxlength="2"></bw-input>
<span>-</span>
<bw-input placeholder="000" id="num-2" maxlength="3"></bw-input>
<span>-</span>
<bw-input placeholder="00" id="num-3" maxlength="2"></bw-input>
</div>
</bw-control>
</div>
<div class="margin-top-sm flex-row gap">
<bw-button type="submit">Submit</bw-button>
<bw-button type="reset">Reset</bw-button>
</div>
</bw-form>

Properties​

PropertyAttributeDescriptionTypeDefault
focusElements--The elements that should be focused when the control is focused.HTMLElement[]undefined
originalValueoriginal-valueThe value the control will reset to. Defaults to the initial value if not set.anyundefined
touchedtouchedWhether or not the control is in a touched state. This is used to control it's CSS states.booleanfalse
validators--Custom validation functions the control will use to determine if it is invalid or not.CustomValidationFn[]undefined
valuevalueThe form value of the control.anyundefined

Events​

EventDescriptionType
validityChangeEmitted when the validity of the control changes. It will emit regardless if it is touched or not.CustomEvent<string>

Methods​

checkValidity() => Promise<boolean>​

Whether or not the control is currently valid.

Returns​

Type: Promise<boolean>

focus() => Promise<void>​

Focuses the first focusable element in the control.

Returns​

Type: Promise<void>

getCustomError() => Promise<string>​

Returns the current custom error message of the control.

Returns​

Type: Promise<string>

getValidatorErrors() => Promise<string[]>​

Returns all the current validation errors of the control.

Returns​

Type: Promise<string[]>

isResetting() => Promise<boolean>​

Returns whether or not the control is currently resetting.

Returns​

Type: Promise<boolean>

setCustomValidity(message: string | null) => Promise<void>​

Sets a custom validity message on the control. Custom errors will go away if the form is reset.

Parameters​

NameTypeDescription
messagestring

Returns​

Type: Promise<void>

Slots​

SlotDescription
The default slot

© 2026 United Systems & Software - All Rights Reserved.