Skip to content

Commit

Permalink
[docs] New API design rule disabled > disable
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Oct 31, 2022
1 parent 30cb27c commit ad02435
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions docs/data/material/guides/api/api.md
Expand Up @@ -91,16 +91,22 @@ Nested components inside a component have:

### Prop naming

The name of a boolean prop should be chosen based on the **default value**. This choice allows:
- **Boolean**
- The default value of a boolean prop should be `false`. This choice allows the shorthand notation For example an input is by default enabled: How to name the prop that controls this state? It should be called `disabled` because:

- the shorthand notation. For example, the `disabled` attribute on an input element, if supplied, defaults to `true`:
```jsx
<Input enabled={false} />
<Input disabled />
```

```jsx
<Input enabled={false} />
<Input disabled />
```
- The name of the boolean, if composed of a single word, should be an adjective or a noun and not a verb. This is because the prop describes a state. For example an input prop can be controlled by a state, which wouldn't be called with a verb:

```jsx
const [disabled, setDisabled] = React.useState(false);

- developers to know what the default value is from the name of the boolean prop. It's always the opposite.
<Input disable={disabled} />
<Input disabled={disabled} />
```

### Controlled components

Expand Down

0 comments on commit ad02435

Please sign in to comment.