The Switch component is a binary choice selection component.

Igx Module
IgxSwitchModule
Igx Theme
igx-switch-theme, igx-tooltip-theme
Igx Keywords
switch, states, tooltip
Igx Group
Data Entry & Display

Remarks

The Ignite UI Switch lets the user toggle between on/off or true/false states.

Example

<igx-switch [checked]="true">
  Simple switch
</igx-switch>
new IgxSwitchComponent(): IgxSwitchComponent

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:244

Returns IgxSwitchComponent

Inherited from: CheckboxBaseDirective

Sets/gets the value of the aria-label attribute.

ariaLabel: string | null = null

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:242

Example

<igx-checkbox aria-label="Checkbox1"></igx-checkbox>
let ariaLabel = this.checkbox.ariaLabel;

Inherited from: CheckboxBaseDirective

Sets/gets the aria-labelledby attribute. If not set, the aria-labelledby will be equal to the value of labelId attribute.

ariaLabelledBy: string

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:228

Example

<igx-checkbox aria-labelledby="Checkbox1"></igx-checkbox>
let ariaLabelledBy = this.checkbox.ariaLabelledBy;

Inherited from: CheckboxBaseDirective

An event that is emitted after the checkbox state is changed. Provides references to the checkbox and the checked property as event arguments.

change: EventEmitter<IChangeCheckboxEventArgs>

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:31

Returns the class of the switch component.

cssClass: string = 'igx-switch'

Defined in projects/igniteui-angular/switch/src/switch/switch.component.ts:61

Example

let switchClass = this.switch.cssClass;

Sets/gets the disabled attribute. Default value is false.

disabled: boolean = false

Defined in projects/igniteui-angular/switch/src/switch/switch.component.ts:90

Example

<igx-switch disabled><igx-switch>

Inherited from: CheckboxBaseDirective

Enables/Disables the ripple effect. If not set, disableRipple will have value false.

disableRipple: boolean = false

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:213

Example

<igx-checkbox [disableRipple]="true"></igx-checkbox>
let isRippleDisabled = this.checkbox.desableRipple;

Sets/gets whether the switch component is on focus. Default value is false.

focused: boolean = false

Defined in projects/igniteui-angular/switch/src/switch/switch.component.ts:123

Example

this.switch.focused = true;

Inherited from: CheckboxBaseDirective

Sets/gets the id of the checkbox component. If not set, the id of the first checkbox component will be "igx-checkbox-0".

id: string

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:130

Example

<igx-checkbox id="my-first-checkbox"></igx-checkbox>
let checkboxId =  this.checkbox.id;

Inherited from: CheckboxBaseDirective

Sets/gets the id of the label element. If not set, the id of the label in the first checkbox component will be "igx-checkbox-0-label".

labelId: string

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:144

Example

<igx-checkbox labelId="Label1"></igx-checkbox>
let labelId =  this.component.labelId;

Inherited from: CheckboxBaseDirective

Sets/gets the position of the label. If not set, the labelPosition will have value "after".

labelPosition: string = LabelPosition.AFTER

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:198

Example

<igx-checkbox labelPosition="before"></igx-checkbox>
let labelPosition =  this.checkbox.labelPosition;

Inherited from: CheckboxBaseDirective

Sets/gets the name attribute.

name: string

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:170

Example

<igx-checkbox name="Checkbox1"></igx-checkbox>
let name =  this.checkbox.name;

Inherited from: CheckboxBaseDirective

Returns reference to the native checkbox element.

nativeInput: ElementRef

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:49

Example

let checkboxElement =  this.component.checkboxElement;

Inherited from: CheckboxBaseDirective

Returns reference to the native label element.

@example
let labelElement =  this.component.nativeLabel;
nativeLabel: ElementRef

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:60

Inherited from: CheckboxBaseDirective

Returns reference to the label placeholder element.

@example
let labelPlaceholder =  this.component.placeholderLabel;
placeholderLabel: ElementRef

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:114

Inherited from: CheckboxBaseDirective

Sets/gets the value of the tabindex attribute.

tabindex: number

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:183

Example

<igx-checkbox [tabindex]="1"></igx-checkbox>
let tabIndex =  this.checkbox.tabindex;

Inherited from: CheckboxBaseDirective

Sets/gets the value attribute.

value: any

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:157

Example

<igx-checkbox [value]="'CheckboxValue'"></igx-checkbox>
let value =  this.checkbox.value;
get checked(): boolean

Defined in projects/igniteui-angular/switch/src/switch/switch.component.ts:76

Returns boolean

Sets/gets whether the switch is on or off. Default value is 'false'.

set checked(value: boolean): void

Defined in projects/igniteui-angular/switch/src/switch/switch.component.ts:73

Example

<igx-switch [checked]="true"></igx-switch>

Parameters

  • value: boolean

Returns void

Sets/gets whether the switch component is invalid. Default value is false.

get invalid(): boolean

Defined in projects/igniteui-angular/switch/src/switch/switch.component.ts:106

Example

<igx-switch invalid></igx-switch>
let isInvalid = this.switch.invalid;

Returns boolean

set invalid(value: boolean): void

Defined in projects/igniteui-angular/switch/src/switch/switch.component.ts:109

Parameters

  • value: boolean

Returns void

Inherited from: CheckboxBaseDirective

Returns reference to the nativeElement of the igx-checkbox/igx-switch.

get nativeElement(): any

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:101

Example

let nativeElement = this.component.nativeElement;

Returns any

Inherited from: CheckboxBaseDirective

Sets/gets whether the checkbox is required. If not set, required will have value false.

get required(): boolean

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:263

Example

<igx-checkbox required></igx-checkbox>
let isRequired = this.checkbox.required;

Returns boolean

set required(value: boolean): void

Defined in projects/igniteui-angular/directives/src/directives/checkbox/checkbox-base.directive.ts:266

Parameters

  • value: boolean

Returns void