复选框、单选框、开关
复选框和单选框,支持所有语义色以及 flat、square、circle 样式、分组,另有开关(switch)。
复选框与单选框
复选框与单选框
vue
<div class="thl-stack">
<div class="thl-demo-row"><ThlCheckbox v-model="a" :label="`Checked: ${a}`" /><ThlCheckbox indeterminate label="Indeterminate" /><ThlCheckbox disabled label="Disabled" /></div>
<div class="thl-demo-row"><ThlCheckbox v-for="c in colors" :key="c" :color="c" :model-value="true" :label="c" /></div>
<div class="thl-demo-row"><ThlCheckbox v-for="s in ['flat','square','circle']" :key="s" :skin="s" color="success" :model-value="true" :label="s" /></div>
<ThlCheckboxGroup v-model="group" :options="[{ label: 'A', value: 'a' }, { label: 'B', value: 'b' }, { label: 'C (disabled)', value: 'c', disabled: true }]" />
<ThlRadioGroup v-model="gender" color="info" :options="[{ label: 'Male', value: 'm' }, { label: 'Female', value: 'f' }, { label: 'Other', value: 'o' }]" />
</div>tsx
<Checkbox checked={a} onChange={setA} label="Checked" />
<Checkbox color="success" skin="flat" defaultChecked label="flat" />
<CheckboxGroup value={group} onChange={setGroup} options={[{ label: 'A', value: 'a' }, { label: 'B', value: 'b' }]} />
<RadioGroup value={gender} onChange={setGender} color="info" options={genders} />html
<thl-checkbox [(checked)]="a" label="Checked" />
<thl-checkbox color="success" skin="flat" [checked]="true" label="flat" />
<thl-checkbox-group [(value)]="group" [options]="opts" />
<thl-radio-group formControlName="gender" color="info" [options]="genders" />Switch
Switch
vue
<div class="thl-stack">
<ThlSwitch v-model="on" :label="`Switch: ${on}`" />
<div class="thl-demo-row"><ThlSwitch v-for="c in colors" :key="c" :color="c" :model-value="true" /></div>
<div class="thl-demo-row"><ThlSwitch size="sm" :model-value="true" /><ThlSwitch :model-value="true" /><ThlSwitch size="lg" :model-value="true" /><ThlSwitch disabled /></div>
</div>tsx
<Switch checked={on} onChange={setOn} label="Switch" />
<Switch color="success" size="lg" defaultChecked />html
<thl-switch [(checked)]="on" label="Switch" />
<thl-switch color="success" size="lg" [checked]="true" />API
Checkbox
<ThlCheckbox> · import { ThlCheckbox } from '@thl-ui/vue'
| Prop | 类型 | 默认值 |
|---|---|---|
modelValue | any | — |
value | any | — |
color | string | — |
label | string | — |
indeterminate | boolean | — |
skin | string | — |
disabled | boolean | — |
事件: update:modelValuechange
插槽: default
Radio
<ThlRadio> · import { ThlRadio } from '@thl-ui/vue'
| Prop | 类型 | 默认值 |
|---|---|---|
modelValue | any | — |
value | any | — |
color | string | — |
label | string | — |
skin | string | — |
disabled | boolean | — |
name | string | — |
事件: update:modelValue
插槽: default
CheckboxGroup
<ThlCheckboxGroup> · import { ThlCheckboxGroup } from '@thl-ui/vue'
| Prop | 类型 | 默认值 |
|---|---|---|
modelValue | array | — |
options* | array | — |
color | string | — |
vertical | boolean | — |
事件: update:modelValue
RadioGroup
<ThlRadioGroup> · import { ThlRadioGroup } from '@thl-ui/vue'
| Prop | 类型 | 默认值 |
|---|---|---|
modelValue | any | — |
options* | array | — |
color | string | — |
vertical | boolean | — |
name | string | — |
事件: update:modelValue
Switch
<ThlSwitch> · import { ThlSwitch } from '@thl-ui/vue'
| Prop | 类型 | 默认值 |
|---|---|---|
modelValue | boolean | — |
color | string | — |
size | string | — |
label | string | — |
disabled | boolean | — |
事件: update:modelValue