A check box allowing single values to be selected/deselected.
- Element
-
igc-checkbox
- Slots
-
default— The checkbox label. -
helper-text— Renders content below the input. -
value-missing— Renders content when the required validation fails. -
custom-error— Renders content when setCustomValidity(message) is set. -
invalid— Renders content when the component is in invalid state (validity.valid = false).
- CSS Parts
-
base— The base wrapper of the checkbox. -
control— The box of the checkbox. It holds the indicator. -
label— The checkbox label. -
indicator— The checkbox indicator icon. -
checked— Added to the base, control, label and indicator parts when the checkbox is checked. -
focused— Added to the base part when the checkbox has keyboard focus.
Properties
Section titled "Properties"disabled
Section titled "disabled"Inherited from: IgcCheckboxBaseComponent
Whether the control is disabled. A disabled control is not validated, and the form does not submit its value.
disabled: boolean Defined in src/internals/mixins/forms/types.ts:35
indeterminate
Section titled "indeterminate"Whether the checkbox is in the indeterminate state. A user click clears it.
indeterminate: boolean = false Defined in src/components/checkbox/checkbox.ts:61
invalid
Section titled "invalid"Inherited from: IgcCheckboxBaseComponent
Whether the control shows the invalid state. It changes only the visual state, not the validity.
invalid: boolean Defined in src/internals/mixins/forms/types.ts:43
labelPosition
Section titled "labelPosition"Inherited from: IgcCheckboxBaseComponent
The label position of the control.
labelPosition: ToggleLabelPosition = 'after' Defined in src/components/checkbox/checkbox-base.ts:93
Inherited from: IgcCheckboxBaseComponent
The name of the control, submitted with the form data.
name: string Defined in src/internals/mixins/forms/types.ts:49
styles
Section titled "styles"Array of styles to apply to the element. The styles should be defined using the css tag function, via constructible stylesheets, or imported from native CSS module scripts.
Note on Content Security Policy:
Element styles are implemented with <style> tags when the browser doesn't
support adopted StyleSheets. To use such <style> tags with the style-src
CSP directive, the style-src value must either include 'unsafe-inline' or
nonce-<base64-value> with <base64-value> replaced be a server-generated
nonce.
To provide a nonce to use on generated <style> elements, set
window.litNonce to a server-generated nonce in your page's HTML, before
loading application code:
``
styles: CSSResult[] Defined in src/components/checkbox/checkbox.ts:44
Accessors
Section titled "Accessors"checked
Section titled "checked"Inherited from: IgcCheckboxBaseComponent
get checked(): any Defined in src/components/checkbox/checkbox-base.ts:80
Whether the control is checked.
set checked(value: boolean): void Defined in src/components/checkbox/checkbox-base.ts:80
Parameters
- value:
boolean
Returns void
defaultChecked
Section titled "defaultChecked"Inherited from: IgcCheckboxBaseComponent
get defaultChecked(): any Defined in src/internals/mixins/forms/types.ts:175
Whether the control is checked by default. A form reset restores the
checked state to it. While the checked state is unchanged since the start
or the last form reset, a new default also sets the checked state. The
checked attribute also sets it.
set defaultChecked(value: boolean): void Defined in src/internals/mixins/forms/types.ts:175
Parameters
- value:
boolean
Returns void
Inherited from: IgcCheckboxBaseComponent
The form that the control is associated with, or null.
get form(): HTMLFormElement | null Defined in src/internals/mixins/forms/types.ts:52
Returns HTMLFormElement | null
required
Section titled "required"Inherited from: IgcCheckboxBaseComponent
get required(): any Defined in src/internals/mixins/forms/types.ts:188
Whether the control is required. A required control that has no value, or is not checked, fails validation.
set required(value: boolean): void Defined in src/internals/mixins/forms/types.ts:188
Parameters
- value:
boolean
Returns void
validationMessage
Section titled "validationMessage"Inherited from: IgcCheckboxBaseComponent
The validation message of the control. It is empty when the control is valid.
get validationMessage(): string Defined in src/internals/mixins/forms/types.ts:61
Returns string
validity
Section titled "validity"Inherited from: IgcCheckboxBaseComponent
The validity state of the control.
get validity(): ValidityState Defined in src/internals/mixins/forms/types.ts:55
Returns ValidityState
value
Section titled "value"Inherited from: IgcCheckboxBaseComponent
get value(): any Defined in src/components/checkbox/checkbox-base.ts:63
The value of the control, submitted when the control is checked.
set value(value: string): void Defined in src/components/checkbox/checkbox-base.ts:63
Parameters
- value:
string
Returns void
willValidate
Section titled "willValidate"Inherited from: IgcCheckboxBaseComponent
Whether the control is a candidate for constraint validation.
get willValidate(): boolean Defined in src/internals/mixins/forms/types.ts:64
Returns boolean
Methods
Section titled "Methods"Inherited from: IgcCheckboxBaseComponent
Removes focus from the control.
blur(): void Defined in src/components/checkbox/checkbox-base.ts:109
Returns void
checkValidity
Section titled "checkValidity"Inherited from: IgcCheckboxBaseComponent
Checks validity and emits invalid when the control is invalid. Returns
true when the control is valid.
checkValidity(): boolean Defined in src/internals/mixins/forms/types.ts:134
Returns boolean
click
Section titled "click"Inherited from: IgcCheckboxBaseComponent
Simulates a click on the control.
click(): void Defined in src/components/checkbox/checkbox-base.ts:96
Returns void
focus
Section titled "focus"Inherited from: IgcCheckboxBaseComponent
Sets focus on the control.
focus(options: FocusOptions): void Defined in src/components/checkbox/checkbox-base.ts:102
Parameters
- options:
FocusOptions
Returns void
reportValidity
Section titled "reportValidity"Inherited from: IgcCheckboxBaseComponent
Checks validity. As for a native control, an invalid control emits
invalid and takes the focus. It shows its own validation messages, not
the message of the browser. Returns true when the control is valid.
reportValidity(): boolean Defined in src/internals/mixins/forms/types.ts:141
Returns boolean
setCustomValidity
Section titled "setCustomValidity"Inherited from: IgcCheckboxBaseComponent
Sets a custom validation message. The control is invalid while the message is not empty. An empty string removes the custom error.
setCustomValidity(message: string): void Defined in src/internals/mixins/forms/types.ts:147
Parameters
- message:
string