Radio
Examples
Radio
value & change
import { ref } from 'vue';
export default {
setup: () => {
const val = ref('a');
const onChange = (e) => {
val.value = e.target.value;
};
return () => (
<>
<dv-radio
checked={val.value === 'a'}
onChange={onChange}
name="radio-2"
value="a"
/>
<dv-radio
checked={val.value === 'b'}
onChange={onChange}
name="radio-2"
value="b"
/>
</>
);
},
};
tsx
Color type
Sizes
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');
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-radio-group
size="lg"
options={options}
disabled={disabled.value}
v-model={value.value}
/>
</div>
);
},
};
tsx
Radio
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 | - |
value | input value | IText | - |
name | input name | string | - |
readOnly | read only status | bool | - |
RadioGroup
Attributes
name | description | type | default |
---|---|---|---|
size | size | ISize | md |
variant | color type | neutral, primary, secondary, accent | neutral |
disabled | disable status | bool | - |
options | options | IOption[] | - |
v-model | v-model for selected value | IText | - |
defaultValue | initial value | IText | - |
CSS variables
name | description | default |
---|---|---|
--dv-radio-gap | checkbox horizontal gap | 8px |