GitHub

Switch

A switch allows users to toggle the state of a single setting.

Components

import { DaffSwitchComponent } from '@daffodil/design/switch'

The switch component provides a way to toggle between two settings.

<daff-switch>Label</daff-switch>
@Component()
class DaffSwitchComponent extends DaffSizableDirective<DaffSwitchSize> {
  @Input() size: T
  @Input() @HostBinding() disabled: boolean = false
  @Input() labelPosition: DaffSwitchLabelPosition = DaffSwitchLabelPositionEnum.LEFT
  @Input() disabled: any
  @Input() checked: boolean = false
  @Input() id: string = 'daff-switch-' + switchIncrementalId++

  @Output() toggled: EventEmitter<boolean> = new EventEmitter<boolean>()
}

Inputs

size
T
Default
Description

The size of the component.

Options are: xs, sm, md, lg, and xl.

disabled
boolean
Defaultfalse
Description
labelPosition
DaffSwitchLabelPosition
DefaultDaffSwitchLabelPositionEnum.LEFT
Description

The position of the label relative to the switch.

disabled
any
Default
Description

Whether the switch is disabled.

checked
boolean
Defaultfalse
Description

Current state of switch (on/off).

id
string
Default'daff-switch-' + switchIncrementalId++
Description

The unique id of the switch. Defaults to an autogenerated value. When using this, it's your responsibility to ensure that the id for each switch is unique.

It gets assigned to the for attribute on the <label> inside of the switch.

Outputs

toggled
EventEmitter
Default
Description

Output event triggered when the switch has been toggled.