Use radio buttons to present each item in a list of options where users must make a single selection.
<script lang="ts" setup>
import { RadioButton } from '@returnless/focus-ui';
const radioButtonModel = ref<string | null>(null);
</script>
<template>
<FormLayout>
<RadioButton
v-model="radioButtonModel"
value="comments"
label="Comments"
help-text="Get notified when someones posts a comment on a posting." />
<RadioButton
v-model="radioButtonModel"
value="candidates"
label="Candidates"
help-text="Get notified when a candidate applies for a job." />
<RadioButton
v-model="radioButtonModel"
value="offers"
label="Offers"
help-text="Get notified when a candidate accepts or rejects an offer." />
</FormLayout>
<pre class="mt-4"></pre>
</template>Radio buttons should:
Radio button labels should:
Screen readers convey the state of the radio button automatically.
disabled prop to apply the HTML disabled attribute to the radio button <input>. This prevents users from being able to interact with the radio button, and conveys its inactive state to assistive technologies.id prop to provide a unique id attribute value for the radio button. If an id isn't provided, then the component generates one. All radio buttons must have unique id values to work correctly with assistive technologies.label prop conveys the purpose of the radio button to all users.labelHidden prop to visually hide the label but make it available to assistive technologies.helpText prop or an inline error message via the error prop, the help or error content is conveyed to screen reader users with the aria-describedBy attribute.