Skip to content

Commit

Permalink
docs: Describe default type attribute in Buttons documentation
Browse files Browse the repository at this point in the history
MUI documentation does not describe default button's `type`, nor
explain that is it possible to set classic HTML attributes, so it is
easy to forget applying the correct button type when inside of a form

This is what happened on a previous PR when migrating from old
`react/deprecated/Button` to new `react/Buttons` as those components
have opposite default behaviors

Related PR: cozy/cozy-settings#674
  • Loading branch information
Ldoppea committed Apr 11, 2024
1 parent 7f785bd commit 8666450
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions react/Buttons/Readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Buttons are a wrapper arround [MuiButton](https://mui.com/material-ui/react-button/) integrated with Cozy's design system

The `Button` component will produce an HTML `<button>`. The React component accepts classic HTML attributes (i.e. `type`) through React props.

By default the HTML `<button>` is rendered with `type="button"` attribute, so its click effect must be controlled by React (i.e. by using `onClick` event).

If the button is located inside of a form, you can set the props `type="submit"` to the React component, so clicking on it would trigger the form's `onSubmit` event.

### Default

```jsx
Expand Down

0 comments on commit 8666450

Please sign in to comment.