Skip to content

Commit 57a651c

Browse files
committed
[no ci] [Doc] Document how to support line-breaks in notifications
1 parent 7dc6c23 commit 57a651c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

docs/useNotify.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ notify(
145145
);
146146
```
147147

148+
You also need to set the `multiLine` option to `true` when your message contains line breaks (`\n`):
149+
150+
```jsx
151+
notify(
152+
'Line 1\nLine 2\nLine 3',
153+
{ multiLine: true }
154+
);
155+
```
156+
148157
## `type`
149158

150159
This option lets you choose the notification type. It can be `info`, `success`, `warning` or `error`. The default is `info`.

packages/ra-ui-materialui/src/layout/Notification.stories.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,25 @@ export const Multiline = () => (
8181
</Wrapper>
8282
);
8383

84+
const LineBreakNotification = () => {
85+
const notify = useNotify();
86+
React.useEffect(() => {
87+
notify(
88+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.\nSed euismod, nisl nec ultricies aliquam, nisl nisl aliquet nisl, eget aliquet nisl nisl eu nisl.\nSed euismod, nisl nec ultricies aliquam, nisl nisl aliquet nisl, eget aliquet nisl nisl eu nisl.',
89+
{
90+
multiLine: true,
91+
}
92+
);
93+
}, [notify]);
94+
return null;
95+
};
96+
97+
export const LineBreak = () => (
98+
<Wrapper>
99+
<LineBreakNotification />
100+
</Wrapper>
101+
);
102+
84103
const AutoHideDurationNotification = () => {
85104
const notify = useNotify();
86105
React.useEffect(() => {

0 commit comments

Comments
 (0)