# React, how to make a checked checkbox editable

> Learn how to make a React checkbox start checked but still editable by using the defaultChecked attribute instead of checked, which locks the input state.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2021-06-16 | Topics: [React](https://flaviocopes.com/tags/react/) | Canonical: https://flaviocopes.com/react-checkbox-editable/

I had a checkbox in a [React](https://flaviocopes.com/react/) component:

```jsx
<input name="enable" type="checkbox" />
```

and I wanted it to be checked by default, yet the user could change its value.

Using

```jsx
<input name="enable" type="checkbox" checked="checked" />
```

didn't work. The checkbox state could not be changed.

The solution was to use the `defaultChecked` attribute:

```jsx
<input name="enable" type="checkbox" defaultChecked={true} />
```

If the checkbox needs to be checked depending if the value was checked in a variable (for example in an editing form when you are getting the actual value from the database) you can use

```jsx
<input name="enable" type="checkbox" defaultChecked={existing_enable_value} />
```
