Skip to content
On this page

Radio

Augmented form field for choice input.

Usage

See using components for detailed instructions.

js
import { CRadio } from 'chusho';

Config

The options below are to be set in the global configuration at the following location:

js
{
  components: {
    radio: {
      class: ({ checked, modelValue, value, required, disabled, variant }) => {},
    },
  },
}

class

Classes applied to the input element, except when the prop bare is set to true. See styling components.

  • type: Array<String | Object> | Object | String | (props: Object) => {}
  • default: null

Example

js
class({ checked }) {
    return ['radio', {
        'radio--checked': checked,
    }]
}

API

NameTypeDefaultDescription
Props
variant string|array|objectundefined

Useful when used in the component config class option, to style it conditionally. See styling components.

bare booleanfalse

Disable class inheritance from the component config. See styling components.

disabled booleannull

Set the HTML disabled attribute

required booleannull

Set the HTML required attribute

modelValue anynull

Bind the Radio state with the parent component.

value *any

The value to be used when the Radio is checked.

Events
update:modelValue
Emitted when the selected radio changes.
ArgumentTypeDescription
modelValueany

The currently selected radio value.

Examples

Controlled

vue
<template>
  <CRadio v-model="value" value="A" />
  <CRadio v-model="value" value="B" />
  <CRadio v-model="value" value="C" />
</template>

<script>
export default {
  data() {
    return {
      value: null, // None by default
    };
  },
};
</script>

Released under the MIT License.