Skip to content

Switch

<bh-switch> | BharatSwitch

The switch component represents a binary on/off state with support for labels, multiple sizes, and rich customization options.

Basic Usage

Sizes

The Switch component supports three sizes:

Colors & States

Customize active/inactive switch colors and label color:

Checked State

You can set the switch default state as checked by setting the checked property:

Disabled State

You can disable the switch by setting the disabled property:

Properties

PropertyTypeDescription
sizestringSize of the switch: “small”, “medium”, “large”
switchLabelstringOptional label next to the switch
switchCheckedColorstringBackground color when switch is ON
switchDefaultColorstringBackground color when switch is OFF
labelColorstringColor of the switch label text
disabledbooleanIf true, disables interaction
checkedbooleanInitial checked state of the switch

Events

Event NamePayloadDescription
switch-selected{ value, checked }Fired when switch is toggled