![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@react-aria/radio
Advanced tools
@react-aria/radio is a library that provides accessible radio button components for React applications. It is part of the React Aria collection, which focuses on providing high-quality, accessible UI components.
Basic Radio Group
This code demonstrates how to create a basic radio group using @react-aria/radio. It includes a RadioGroup component that manages the state and a Radio component that renders individual radio buttons.
import { useRadioGroupState } from '@react-stately/radio';
import { useRadioGroup, useRadio } from '@react-aria/radio';
import { useRef } from 'react';
function RadioGroup(props) {
let state = useRadioGroupState(props);
let { radioGroupProps } = useRadioGroup(props, state);
return (
<div {...radioGroupProps}>
{props.children}
</div>
);
}
function Radio(props) {
let ref = useRef();
let { inputProps } = useRadio(props, props.state, ref);
return (
<label>
<input {...inputProps} ref={ref} />
{props.children}
</label>
);
}
export default function App() {
return (
<RadioGroup label="Favorite Pet">
<Radio value="dogs">Dogs</Radio>
<Radio value="cats">Cats</Radio>
</RadioGroup>
);
}
Custom Styling
This code demonstrates how to apply custom styling to the radio group and radio buttons using CSS classes. The styles are defined in an external stylesheet (styles.css).
import { useRadioGroupState } from '@react-stately/radio';
import { useRadioGroup, useRadio } from '@react-aria/radio';
import { useRef } from 'react';
import './styles.css';
function RadioGroup(props) {
let state = useRadioGroupState(props);
let { radioGroupProps } = useRadioGroup(props, state);
return (
<div {...radioGroupProps} className="radio-group">
{props.children}
</div>
);
}
function Radio(props) {
let ref = useRef();
let { inputProps } = useRadio(props, props.state, ref);
return (
<label className="radio-label">
<input {...inputProps} ref={ref} className="radio-input" />
{props.children}
</label>
);
}
export default function App() {
return (
<RadioGroup label="Favorite Pet">
<Radio value="dogs">Dogs</Radio>
<Radio value="cats">Cats</Radio>
</RadioGroup>
);
}
Disabled Radio Buttons
This code demonstrates how to create a radio group with disabled radio buttons. The 'isDisabled' prop is used to disable specific radio buttons.
import { useRadioGroupState } from '@react-stately/radio';
import { useRadioGroup, useRadio } from '@react-aria/radio';
import { useRef } from 'react';
function RadioGroup(props) {
let state = useRadioGroupState(props);
let { radioGroupProps } = useRadioGroup(props, state);
return (
<div {...radioGroupProps}>
{props.children}
</div>
);
}
function Radio(props) {
let ref = useRef();
let { inputProps } = useRadio(props, props.state, ref);
return (
<label>
<input {...inputProps} ref={ref} disabled={props.isDisabled} />
{props.children}
</label>
);
}
export default function App() {
return (
<RadioGroup label="Favorite Pet">
<Radio value="dogs">Dogs</Radio>
<Radio value="cats" isDisabled={true}>Cats</Radio>
</RadioGroup>
);
}
react-radio-group is a simple and flexible radio group component for React. It provides a straightforward API for creating radio groups and handling their state. Compared to @react-aria/radio, it is less focused on accessibility features but is easier to use for basic use cases.
react-radio-buttons is another library for creating radio button groups in React. It offers a set of customizable radio button components with support for themes and custom styles. While it provides more styling options, it may not be as robust in terms of accessibility as @react-aria/radio.
react-accessible-form is a library that provides accessible form components, including radio buttons. It focuses on ensuring that all form elements are accessible and compliant with ARIA standards. It is similar to @react-aria/radio in its emphasis on accessibility but offers a broader range of form components.
This package is part of react-spectrum. See the repo for more details.
FAQs
Spectrum UI components in React
The npm package @react-aria/radio receives a total of 0 weekly downloads. As such, @react-aria/radio popularity was classified as not popular.
We found that @react-aria/radio demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.