Class IgcSwitchComponent

Similar to a checkbox, a switch controls the state of a single setting on or off.

Element

igc-switch

Slot

  • The switch label.

Fires

igcChange - Emitted when the control's checked state changes.

Fires

igcFocus - Emitted when the control gains focus.

Fires

igcBlur - Emitted when the control loses focus.

Csspart

base - The base wrapper of the switch.

Csspart

control - The switch control.

Csspart

thumb - The position indicator of the switch.

Csspart

label - The switch label.

Hierarchy

  • IgcCheckboxBaseComponent
    • IgcSwitchComponent

Constructors

Properties

ariaLabelledby: string

Sets the aria-labelledby attribute for the control.

checked: boolean = false

The checked state of the control.

Attr

disabled: boolean = false

Disables the control.

Attr

invalid: boolean = false

Controls the validity of the control.

Attr

labelPosition: "after" | "before" = 'after'

The label position of the control.

Attr

label-position

name: string

The name attribute of the control.

Attr

required: boolean = false

Makes the control a required field.

Attr

value: string

The value attribute of the control.

Attr

styles: CSSResult = styles
tagName: "igc-switch" = 'igc-switch'

Methods

  • Checks for validity of the control and emits the invalid event if it invalid.

    Returns boolean

  • Type Parameters

    • K extends keyof IgcCheckboxEventMap

    • D extends boolean | void

    Parameters

    • type: K
    • Optional eventInitDict: CustomEventInit<D>

    Returns boolean

  • Sets focus on the control.

    Parameters

    • Optional options: FocusOptions

    Returns void

  • Checks for validity of the control and shows the browser message if it invalid.

    Returns boolean

  • Sets a custom validation message for the control. As long as message is not empty, the control is considered invalid.

    Parameters

    • message: string

    Returns void