FormRadio
Using the FormRadioGroup and FormRadio components to create a Form with custom validation that requires a user to select an option from a list of radio buttons.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546import * as Ariakit from "@ariakit/react";import { useId } from "react";import "./style.css";export default function Example() {const id = useId();if (!form.getValue(form.names.color)) {form.setError(form.names.color, "Please select a color.");}});alert(JSON.stringify(state.values));});return (<h2 id={id} className="heading">Preferences</h2>Favorite color<label className="radio-label">Red</label><label className="radio-label">Green</label><label className="radio-label">Blue</label>);}import * as Ariakit from "@ariakit/react";import { useId } from "react";import "./style.css";export default function Example() {const id = useId();if (!form.getValue(form.names.color)) {form.setError(form.names.color, "Please select a color.");}});alert(JSON.stringify(state.values));});return (<h2 id={id} className="heading">Preferences</h2>Favorite color<label className="radio-label">Red</label><label className="radio-label">Green</label><label className="radio-label">Blue</label>);}