packages/components/eui-slide-toggle/eui-slide-toggle.component.ts
Slide toggle component used to represent a boolean state. It can be used as a standalone toggle or integrated with Angular Reactive Forms. Supports icons for ON/OFF states and visual variants via EUI base state directives.
<!-- Simple toggle -->
<eui-slide-toggle [(isChecked)]="enabled" />
<!-- With icons -->
<eui-slide-toggle
[iconSvgNameOn]="'check'"
[iconSvgNameOff]="'close'"
[(isChecked)]="enabled" />
<!-- Reactive forms -->
<form [formGroup]="form">
<eui-slide-toggle formControlName="notifications" />
</form>
| changeDetection | ChangeDetectionStrategy.OnPush |
| HostDirectives |
BaseStatesDirective
Inputs : euiPrimary euiSecondary euiInfo euiWarning euiSuccess euiDanger euiVariant euiSizeS euiSizeM euiSizeL euiSizeXL euiSizeVariant
|
| selector | eui-slide-toggle |
| imports |
ReactiveFormsModule
EUI_ICON
|
| templateUrl | ./eui-slide-toggle.component.html |
| styleUrl | ./eui-slide-toggle.scss |
Properties |
|
Methods |
|
Inputs |
Outputs |
HostBindings |
Accessors |
constructor()
|
| ariaLabel |
Type : string
|
Default value : 'eUI slide toggle'
|
|
attribute attached to the aria-label of the input field |
| disabled |
Type : boolean
|
|
Whether the toggle is disabled |
| iconSvgFillColorOff |
Type : string
|
Default value : 'secondary'
|
|
Fill color for the OFF state icon |
| iconSvgFillColorOn |
Type : string
|
Default value : 'secondary'
|
|
Fill color for the ON state icon |
| iconSvgNameOff |
Type : string
|
|
Name of the icon to display when toggle is OFF |
| iconSvgNameOn |
Type : string
|
|
Name of the icon to display when toggle is ON |
| id |
Type : string
|
Default value : `eui-slide-toggle-${uniqueId()}`
|
|
Unique identifier for the toggle |
| isChecked |
Type : boolean
|
Default value : false
|
|
Current checked state of the toggle |
| slideToggleChange |
Type : EventEmitter
|
|
Event emitted when toggle state changes |
| class |
Type : string
|
|
CSS classes applied to the host element |
| Public onFocusOut |
onFocusOut()
|
|
Handles focus out event Notifies form control of touch event
Returns :
void
|
| Public registerOnChange | ||||||
registerOnChange(fn: any)
|
||||||
|
Implements ControlValueAccessor Registers change handler
Parameters :
Returns :
void
|
| Public registerOnTouched | ||||||
registerOnTouched(fn: any)
|
||||||
|
Implements ControlValueAccessor Registers touch handler
Parameters :
Returns :
void
|
| Public setDisabledState | ||||||
setDisabledState(isDisabled: boolean)
|
||||||
|
Implements ControlValueAccessor Updates the toggle's disabled state
Parameters :
Returns :
void
|
| Public toggle |
toggle()
|
|
Toggles the current state if not disabled Emits the new state and notifies form control
Returns :
void
|
| Public writeValue | ||||||
writeValue(value: boolean)
|
||||||
|
Implements ControlValueAccessor Updates the toggle's checked state
Parameters :
Returns :
void
|
| Public checkboxControl |
Type : unknown
|
Default value : new FormControl()
|
|
Form control for the toggle when used in reactive forms |
| cssClasses |
getcssClasses()
|
|
CSS classes applied to the host element
Returns :
string
|
| disabled | ||||||
getdisabled()
|
||||||
setdisabled(value: boolean)
|
||||||
|
Whether the toggle is disabled
Parameters :
Returns :
void
|