Checkbox
Examples
Checkbox
With label
Color type
export default {
setup: () => {
const types = ['neutral', 'primary', 'secondary', 'accent'];
return () => (
<div class="flex flex-col items-center space-y-4">
{types.map((type) => (
<div key={type} class="w-32">
<dv-checkbox variant={type} defaultChecked>
{type}
</dv-checkbox>
</div>
))}
</div>
);
},
};
tsx
Sizes
Disabled
Indeterminate(style only, do not affect the value)
Group
import { ref } from 'vue';
export default {
setup: () => {
const options = [
{ value: 'apple', label: 'Apple' },
{ value: 'pear', label: 'Pear' },
{ value: 'orange', label: 'Orange' },
];
const value = ref(['apple', 'pear']);
const disabled = ref(false);
return () => (
<div>
<div class="flex items-center">
<label class="mr-4">Disabled:</label>
<dv-toggle
checked={disabled.value}
onChange={(e) => (disabled.value = e.target.checked)}
/>
</div>
<dv-divider />
<dv-checkbox-group
size="lg"
options={options}
disabled={disabled.value}
v-model={value.value}
/>
</div>
);
},
};
tsx
Checkbox
Attributes
name | description | type | default |
---|---|---|---|
size | size | ISize | md |
variant | color type | neutral, primary, secondary, accent | neutral |
disabled | disable status | bool | - |
checked | checked status | bool | - |
onChange | change callback | Function | - |
defaultChecked | initial checked status | bool | - |
readOnly | read only status | bool | - |
options | checkbox options | IOption[] | - |
indeterminate | indeterminate status. style only, do not affect the value | bool | - |
CheckboxGroup
Attributes
name | description | type | default |
---|---|---|---|
v-model | v-model for selected values | IText[] | - |
size | size | ISize | md |
variant | color type | neutral, primary, secondary, accent | neutral |
disabled | disable status | bool | - |
options | options | IOption[] | - |
defaultValue | initial values | IText[] | - |
CSS variables
name | description | default |
---|---|---|
--dv-checkbox-gap | checkbox horizontal gap | 8px |