Skip to content

Commit f8054c8

Browse files
committed
Improve Button documentation
1 parent cdca12e commit f8054c8

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

docs/Buttons.md

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,83 @@ Base component for most react-admin buttons. Responsive (displays only the icon
552552
| Prop | Required | Type | Default | Description |
553553
| ------------ | -------- | ------------------------------ | ------- | ---------------------------------------- |
554554
| `alignIcon` | Optional | `'left' | 'right` | `'left'` | Icon position relative to the label |
555-
| `children` | Optional | `ReactElement` | - | icon to use |
555+
| `children` | Optional | `ReactNode` | - | icon to use |
556556
| `className` | Optional | `string` | - | Class name to customize the look and feel of the button element itself |
557557
| `color` | Optional | `'default' | 'inherit'| 'primary' | 'secondary'` | `'primary'` | Label and icon color |
558558
| `disabled` | Optional | `boolean` | `false` | If `true`, the button will be disabled |
559+
| `label` | Optional | `ReactNode` | `false` | The button label |
559560
| `size` | Optional | `'large' | 'medium' | 'small'` | `'small'` | Button size |
560561

561562
Other props are passed down to [the underlying Material UI `<Button>`](https://mui.com/material-ui/api/button/).
562563

564+
### `alignIcon`
565+
566+
The icon position relative to the label. Defaults to `left`.
567+
568+
```tsx
569+
<Button label="Ban user" onClick={handleClick} alignIcon="right" />
570+
```
571+
572+
### `children`
573+
574+
The button icon:
575+
576+
```tsx
577+
<Button label="Ban user" onClick={handleClick}>
578+
<BanIcon />
579+
</Button>
580+
```
581+
582+
### `className`
583+
584+
The button CSS classes:
585+
586+
```tsx
587+
<Button label="Ban user" onClick={handleClick} className="ban-button" />
588+
```
589+
590+
### `color`
591+
592+
The button label and icon color. Accepts `default`, `inherit`, `primary`, `secondary` or `error`.
593+
594+
```tsx
595+
<Button label="Ban user" onClick={handleClick} color="secondary" />
596+
```
597+
598+
### `disabled`
599+
600+
A boolean value indicating whether the button is disabled.
601+
602+
```tsx
603+
<Button label="Ban user" onClick={handleClick} disabled={canBanUsers} />
604+
```
605+
606+
### `label`
607+
608+
A ReactNode used as the button label.
609+
610+
If you pass a string, it will be automatically translated, so you can use either a simple string or a translation key:
611+
612+
```tsx
613+
<Button label="Ban user" onClick={handleClick} />
614+
<Button label="myapp.actions.ban_user" onClick={handleClick} />
615+
```
616+
617+
Pass `false` or `null` if you don't want a label at all:
618+
619+
```tsx
620+
<Button label={false} onClick={handleClick} />
621+
<Button label={null} onClick={handleClick} />
622+
```
623+
624+
### `size`
625+
626+
The button size. Accepts `large`, `medium` or `small`. Defaults to `small`.
627+
628+
```tsx
629+
<Button label="Ban user" onClick={handleClick} size="large" />
630+
```
631+
563632
### `sx`: CSS API
564633

565634
| Rule name | Description |

0 commit comments

Comments
 (0)