Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions blog/react-radio-button/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const RadioButton = ({ label, value, onChange }) => {

Our Radio Button component is a [reusable component](/react-reusable-components) now. For example, if you would give your input field some [CSS style in React](/react-css-styling), every Radio Button component which is used in your React project would use the same style.

If you would want to create a radio button group now, you could just use multiple Radio Button components side by side and maybe style them with some border and some alignment, so that a user perceives them as a group of radio buttons:
If you would want to create a radio button group now, you could just use multiple Radio Button components side by side inside a fieldset element, with a legend so that the user (and more importantly, screen readers) perceive them as a group of options.:

```javascript
const App = () => {
Expand All @@ -108,7 +108,8 @@ const App = () => {
};

return (
<div>
<fieldset>
<legend>What sort of pet person are you?</legend>
<RadioButton
label="Cat"
value={catPerson}
Expand All @@ -119,7 +120,7 @@ const App = () => {
value={dogPerson}
onChange={handleDogChange}
/>
</div>
</fieldset>
);
};
```
Expand Down Expand Up @@ -155,4 +156,4 @@ const App = () => {
};
```

That's is it for creating a Radio Button component in React. If you are a beginner in React, I hope this tutorial helped you to understand some concepts and patterns!
That's is it for creating a Radio Button component in React. If you are a beginner in React, I hope this tutorial helped you to understand some concepts and patterns!