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

Hierarchy

  • IgcCheckboxBaseComponent
    • IgcSwitchComponent

Constructors

Properties

checked: boolean = false

The checked state of the control.

Attr

disabled: boolean

The disabled state of the component

Attr

[disabled=false]

invalid: boolean

Control 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

Makes the control a required field in a form context.

Attr

value: string

The value attribute of the control.

Attr

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

Accessors

  • get validity(): ValidityState
  • Returns a ValidityState object which represents the different validity states the element can be in, with respect to constraint validation.

    Returns ValidityState

  • get willValidate(): boolean
  • A boolean value which returns true if the element is a submittable element that is a candidate for constraint validation.

    Returns boolean

Methods

  • Type parameters

    Type Parameters

    • K extends keyof IgcCheckboxEventMap

    • D extends boolean | void

    Parameters

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

    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