Skip to content

KSwitch

Use Switch to store contents.

Install

bash
pnpm add @ikun-ui/switch
bash
yarn add @ikun-ui/switch
bash
npm install @ikun-ui/switch

Basic usage

Disabled switch

Use disabled attribute to determine whether a switch is disabled.

Loading switch

Use disabled attribute to determine whether a switch is loading.

Custom color switch

Custom switch value

Custom switch render

Sizes

Use the size property to control the switch size. It supports enumerations such as md, sm, and lg.

Switch Props

NameTypeDefaultDescription
valuebooleanfalseBinding value
unCheckedValuestring / number / booleanfalseUnChecked state switch value
checkedValuestring / number / booleantrueChecked state switch value
unCheckedColorstring-unChecked state switch color
checkedColorstring-Checked state switch color
sizesm | md | lgmdsize of switch
loadingboolean-Loading state switch
disabledbooleanfalseDisabled the switch
clsstring-Additional class
attrsRecord<string, string>{}Additional attributes

Switch Events

NameDescriptionType
clickTriggered when the switch is clicked(value: Event)=> void
updateValueTriggered when the value in the switch binding changes(value: Event)=> void
changeTriggered when the value in the switch binding changes(value: Event)=> void

Switch Slots

NameDescription
unCheckedRenderCustomize content of the uncheked state switch
checkedRenderCustomize content of the cheked state switch

MIT Licensed