Reference Source
import {Switch} from '@adobe/coral-spectrum'
public class | source

Switch

Expression Extends:

class Switch extends BaseFormField(BaseComponent(HTMLElement))

A Switch component is a toggle form field similar to a Checkbox component.

See:

Example:

Markup
<coral-switch></coral-switch>
JS constructor
new Coral.Switch();

Member Summary

Public Members
public

Whether the switch is on or off.

public

Whether this field is disabled or not.

public

The switch's label element.

  • content-zone

public

Inherited from BaseFormField#labelled.

public

Name used to submit the data in a form.

public

Whether this field is readOnly or not.

public

Whether this field is required or not.

public

The value that will be submitted when the checkbox is checked.

Method Summary

Public Methods
public

clear()

Inherited from BaseFormField#clear.

public

reset()

Inherited from BaseFormField#reset.

Public Members

public checked: Boolean source

Whether the switch is on or off.

  • false by default.
  • reflected

Emit:

change

public disabled: Boolean source

Whether this field is disabled or not.

  • false by default.
  • reflected

public label: SwitchLabel source

The switch's label element.

  • content-zone

public labelled: * source

Inherited from BaseFormField#labelled.

public name: String source

Name used to submit the data in a form.

  • "" by default.
  • reflected

public readOnly: Boolean source

Whether this field is readOnly or not. Indicating that the user cannot modify the value of the control.

  • false by default.
  • reflected

public required: Boolean source

Whether this field is required or not.

  • false by default.
  • reflected

public value: String source

The value that will be submitted when the checkbox is checked. Changing this value will not trigger an event.

  • "on" by default.

Public Methods

public clear() source

Inherited from BaseFormField#clear.

public reset() source

Inherited from BaseFormField#reset.