packages/components/eui-input-checkbox/eui-input-checkbox.component.ts
Checkbox input field that allows users to select or deselect a boolean value. Supports standard checked state, disabled and readonly modes, validation feedback, and an optional indeterminate (mixed) state.
Angular component that provides a custom checkbox input implementation. Extends InputDirective and implements form control functionality.
<input euiInputCheckBox id="terms" [(ngModel)]="acceptTerms" />
<label for="terms">I accept the terms and conditions</label><input euiInputCheckBox [indeterminate]="someItemsSelected" />for attribute or wrap in <label>aria-label based on checked stateisInvalid to communicate validation errors to screen readers
OnInit
DoCheck
OnChanges
ControlValueAccessor
| selector | input[euiInputCheckBox] |
| styleUrls | ./eui-input-checkbox.scss |
Methods |
Inputs |
Outputs |
HostBindings |
HostListeners |
Accessors |
constructor()
|
| checked |
Type : boolean
|
|
Controls the checked state of the checkbox. |
| indeterminate |
Type : boolean
|
|
Controls the indeterminate (mixed) state of the checkbox. When true, the checkbox appears in an indeterminate state. This state is automatically cleared when the checkbox is clicked. |
| isInvalid |
Type : boolean
|
|
Controls the invalid state of the checkbox. Used for displaying validation errors. |
| disabled |
Type : boolean
|
| euiDanger |
Type : boolean
|
Default value : false
|
| euiDisabled |
Type : boolean
|
Default value : false
|
| placeholder |
Type : string | null
|
| readonly |
Type : any
|
| indeterminateChange |
Type : EventEmitter<boolean>
|
|
Event emitter that fires when the indeterminate state changes. |
| attr.aria-label |
Type : string
|
|
Attaches an aria-label attribute based on the checked state. |
| attr.type |
Type : string
|
Default value : 'checkbox'
|
| class |
Type : string
|
|
Gets the CSS classes for the checkbox component. Combines base classes with validation state classes. |
| change | ||||||
Arguments : '$any($event.target).checked'
|
||||||
change(checked: boolean)
|
||||||
|
Event handler for checkbox change events.
Parameters :
|
| registerOnChange | ||||||
registerOnChange(fn: any)
|
||||||
|
Parameters :
Returns :
void
|
| registerOnTouched | ||||||
registerOnTouched(fn: any)
|
||||||
|
Parameters :
Returns :
void
|
| Optional setDisabledState | ||||||
setDisabledState(isDisabled: boolean)
|
||||||
|
Parameters :
Returns :
void
|
| writeValue | ||||||||
writeValue(obj: boolean)
|
||||||||
|
Implements ControlValueAccessor writeValue method. Updates the checked state of the checkbox.
Parameters :
Returns :
void
|
| getCssClasses | ||||||
getCssClasses(rootClass: string)
|
||||||
|
Parameters :
Returns :
string
|
| cssClasses |
getcssClasses()
|
|
Gets the CSS classes for the checkbox component. Combines base classes with validation state classes.
Returns :
string
|
| indeterminate | ||||||
getindeterminate()
|
||||||
|
Controls the indeterminate (mixed) state of the checkbox. When true, the checkbox appears in an indeterminate state. This state is automatically cleared when the checkbox is clicked.
Returns :
boolean
|
||||||
setindeterminate(value: BooleanInput)
|
||||||
|
Parameters :
Returns :
void
|
| isInvalid | ||||||
getisInvalid()
|
||||||
|
Controls the invalid state of the checkbox. Used for displaying validation errors.
Returns :
boolean
|
||||||
setisInvalid(state: any)
|
||||||
|
Parameters :
Returns :
void
|
| checked | ||||||
getchecked()
|
||||||
|
Controls the checked state of the checkbox.
Returns :
boolean
|
||||||
setchecked(value: BooleanInput)
|
||||||
|
Parameters :
Returns :
void
|
| ariaLabel |
getariaLabel()
|
|
Attaches an aria-label attribute based on the checked state.
Returns :
string
|