ns-switch
Overview
The ns-switch component renders a segmented control. It maps field.options to buttons and stores the selected option value in field.value.
Props and event
field: required field definition with anoptionsarray.size: optional width mapping. Supported values include 52, 64, 72, 80, 96, 128, 144, and 160.placeholder,leading, andtype: compatibility props.- Emits
changewith the selected option value.
Options
Each option should include label and value. The component marks the option as selected when its value matches field.value.
const field = {
name: 'status',
label: 'Status',
type: 'switch',
value: 'enabled',
options: [
{ label: 'Enabled', value: 'enabled' },
{ label: 'Disabled', value: 'disabled' }
],
errors: []
};
<ns-switch :field="field" :size="64" @change="handleStatusChange" />