Skip to content

Commit 997e3b5

Browse files
committed
Update documentation
1 parent 2e5ce15 commit 997e3b5

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

docs/Buttons.md

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ const CommentShow = () => (
10081008
| ------------- | -------- | --------------- | ---------------- | ------------------------------------------------ |
10091009
| `resource` | Optional | `string` | - | Resource to link to, e.g. 'posts' |
10101010
| `record` | Optional | `Object` | - | Record to link to, e.g. `{ id: 12, foo: 'bar' }` |
1011-
| `label` | Optional | `string` | 'ra.action.edit' | Label or translation message to use |
1011+
| `label` | Optional | `string` | - | Label or translation message to use |
10121012
| `icon` | Optional | `ReactElement` | - | Icon element, e.g. `<CommentIcon />` |
10131013
| `scrollToTop` | Optional | `boolean` | `true` | Scroll to top after link |
10141014

@@ -1020,6 +1020,39 @@ It also supports [all the other `<Button>` props](#button).
10201020

10211021
**Tip:** To allow users to edit a record without leaving the current view, use the [`<EditInDialogButton>`](./EditInDialogButton.md) component.
10221022

1023+
### `label`
1024+
1025+
By default, the label for the `<EditButton>` is the translation key `ra.action.edit` that translates to "Edit".
1026+
1027+
You can customize this label by providing a resource specific translation with the key `resources.RESOURCE.action.edit` (e.g. `resources.posts.action.edit`):
1028+
1029+
```js
1030+
// in src/i18n/en.js
1031+
import englishMessages from 'ra-language-english';
1032+
1033+
export const en = {
1034+
...englishMessages,
1035+
resources: {
1036+
posts: {
1037+
name: 'Post |||| Posts',
1038+
action: {
1039+
edit: 'Modify %{recordRepresentation}'
1040+
}
1041+
},
1042+
},
1043+
...
1044+
};
1045+
```
1046+
1047+
You can also customize this label by specifying a custom `label` prop:
1048+
1049+
1050+
```jsx
1051+
export const PostEditButton = () => (
1052+
<EditButton label="Modify" />
1053+
);
1054+
```
1055+
10231056
### `scrollToTop`
10241057

10251058
By default, `<EditButton>` scrolls the page to the top after redirecting. You can disable it as follows:
@@ -1329,7 +1362,7 @@ const CommentEdit = () => (
13291362
| `resource` | Optional | `string` | - | The target resource, e.g. 'posts' |
13301363
| `record` | Optional | `Object` | - | Record to link to, e.g. `{ id: 12, foo: 'bar' }` |
13311364
| `component` | Optional | `ReactElement` | - | Base path to resource, e.g. '/posts' |
1332-
| `label` | Optional | `string` | 'ra.action.show' | Label or translation message to use |
1365+
| `label` | Optional | `string` | - | Label or translation message to use |
13331366
| `icon` | Optional | `ReactElement` | - | Icon element, e.g. `<CommentIcon />` |
13341367
| `scrollToTop` | Optional | `boolean` | `true` | Scroll to top after link |
13351368

@@ -1339,6 +1372,39 @@ It also supports [all the other `<Button>` props](#button).
13391372

13401373
**Tip**: If you want to link to the Show view manually, use the `/{resource}/{record.id}/show` location.
13411374

1375+
### `label`
1376+
1377+
By default, the label for the `<ShowButton>` is the translation key `ra.action.show` that translates to "Show".
1378+
1379+
You can customize this label by providing a resource specific translation with the key `resources.RESOURCE.action.show` (e.g. `resources.posts.action.show`):
1380+
1381+
```js
1382+
// in src/i18n/en.js
1383+
import englishMessages from 'ra-language-english';
1384+
1385+
export const en = {
1386+
...englishMessages,
1387+
resources: {
1388+
posts: {
1389+
name: 'Post |||| Posts',
1390+
action: {
1391+
show: 'Display %{recordRepresentation}'
1392+
}
1393+
},
1394+
},
1395+
...
1396+
};
1397+
```
1398+
1399+
You can also customize this label by specifying a custom `label` prop:
1400+
1401+
1402+
```jsx
1403+
export const PostShowButton = () => (
1404+
<ShowButton label="Display" />
1405+
);
1406+
```
1407+
13421408
### `scrollToTop`
13431409

13441410
By default, `<ShowButton>` scrolls the page to the top after redirecting. You can disable it as follows:

0 commit comments

Comments
 (0)