Switch
# FxSwitch
A toggle switch that represents the transition between two opposing states, commonly used for triggering "on/off" scenarios.
# Basic Usage
Copy
# Text Description
Copy
# Extended Value Types
Copy
# Disabled State
Copy
# Attributes
| Attribute | Description | Type | Options | Default | Platform Support |
|---|---|---|---|---|---|
| value / v-model | Binding value | boolean / string / number | — | — | PC/Mobile |
| disabled | Whether disabled | boolean | — | false | PC/Mobile |
| width | Switch width (px) | number | — | 40 (52 for mobile) | PC/Mobile |
| height | Switch height (px) | number | — | 32 | Mobile only |
| active-icon-class | Icon class when active (overrides active-text) | string | — | — | PC only |
| inactive-icon-class | Icon class when inactive (overrides inactive-text) | string | — | — | PC only |
| active-text | Text description when active | string | — | — | PC only |
| inactive-text | Text description when inactive | string | — | — | PC only |
| active-value | Value when active | boolean / string / number | — | true | PC only |
| inactive-value | Value when inactive | boolean / string / number | — | false | PC only |
| active-color | Background color when active | string | — | #409EFF | PC only |
| inactive-color | Background color when inactive | string | — | #C0CCDA | PC only |
| name | Native name attribute | string | — | — | PC only |
| validate-event | Whether to trigger form validation when state changes | boolean | - | true | PC only |
| size | Component size | string | medium / small / mini | — | PC only |
| tip | Tooltip text on hover | string | — | — | PC only |
# Events
| Event Name | Description | Callback Parameters | Platform Support |
|---|---|---|---|
| change | Triggered when state changes | New state value | PC/Mobile |
# Methods
| Method | Description | Parameters | Platform Support |
|---|---|---|---|
| focus | Focus the Switch component | - | PC only |