@splunk/react-ui 5.7.1 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion.js +6 -6
- package/Anchor.js +2 -1
- package/Box.js +83 -34
- package/CHANGELOG.md +51 -0
- package/Calendar.js +134 -134
- package/Clickable.js +131 -94
- package/CollapsiblePanel.js +175 -137
- package/ComboBox.js +32 -27
- package/ControlGroup.js +92 -91
- package/DefinitionList.js +9 -9
- package/Drawer.d.ts +2 -0
- package/Drawer.js +679 -0
- package/Dropdown.js +27 -18
- package/DualListbox.js +1 -1
- package/File.js +35 -35
- package/JSONTree.js +73 -72
- package/Link.js +2 -2
- package/MIGRATION.md +10 -0
- package/Menu.js +403 -261
- package/Modal.js +263 -252
- package/Monogram.js +2 -2
- package/Multiselect.js +551 -385
- package/Number.js +2 -1
- package/Paginator.js +14 -12
- package/Popover.js +4 -1
- package/README.md +11 -0
- package/RadioBar.js +1 -1
- package/Search.js +111 -95
- package/Select.js +42 -40
- package/SelectBase.js +819 -715
- package/SidePanel.js +346 -167
- package/SlidingPanels.js +11 -11
- package/StepBar.js +7 -7
- package/Switch.js +5 -5
- package/Table.js +116 -119
- package/Text.js +48 -48
- package/TextArea.js +7 -7
- package/TransitionOpen.js +188 -169
- package/docs-llm/Accordion.md +267 -0
- package/docs-llm/Anchor Menu.md +115 -0
- package/docs-llm/Anchor.md +54 -0
- package/docs-llm/AnimationToggle.md +254 -0
- package/docs-llm/Avatar.md +292 -0
- package/docs-llm/Badge.md +212 -0
- package/docs-llm/Breadcrumbs.md +306 -0
- package/docs-llm/Button Group.md +53 -0
- package/docs-llm/Button.md +361 -0
- package/docs-llm/Card Layout.md +286 -0
- package/docs-llm/Card.md +619 -0
- package/docs-llm/Checkbox.md +218 -0
- package/docs-llm/Chip.md +291 -0
- package/docs-llm/Clickable.md +160 -0
- package/docs-llm/Code.md +292 -0
- package/docs-llm/Collapsible Panel.md +744 -0
- package/docs-llm/Color.md +253 -0
- package/docs-llm/Column Layout.md +391 -0
- package/docs-llm/Combo Box.md +540 -0
- package/docs-llm/Control Group.md +594 -0
- package/docs-llm/Date.md +270 -0
- package/docs-llm/Definition List.md +278 -0
- package/docs-llm/Divider.md +216 -0
- package/docs-llm/Drawer.md +414 -0
- package/docs-llm/Dropdown.md +472 -0
- package/docs-llm/Dual Listbox.md +325 -0
- package/docs-llm/File.md +653 -0
- package/docs-llm/Form Rows.md +374 -0
- package/docs-llm/Heading.md +179 -0
- package/docs-llm/Image.md +109 -0
- package/docs-llm/JSON Tree.md +260 -0
- package/docs-llm/Layer.md +74 -0
- package/docs-llm/Layout.md +50 -0
- package/docs-llm/Link.md +318 -0
- package/docs-llm/List.md +189 -0
- package/docs-llm/Markdown.md +179 -0
- package/docs-llm/Menu.md +735 -0
- package/docs-llm/Message Bar.md +236 -0
- package/docs-llm/Message.md +248 -0
- package/docs-llm/Modal.md +443 -0
- package/docs-llm/Monogram.md +159 -0
- package/docs-llm/Multiselect.md +939 -0
- package/docs-llm/Notifications.md +46 -0
- package/docs-llm/Number.md +298 -0
- package/docs-llm/Paginator.md +395 -0
- package/docs-llm/Paragraph.md +148 -0
- package/docs-llm/Phone Number.md +254 -0
- package/docs-llm/Popover.md +166 -0
- package/docs-llm/Progress.md +141 -0
- package/docs-llm/Radio Bar.md +303 -0
- package/docs-llm/Radio List.md +350 -0
- package/docs-llm/Resize.md +362 -0
- package/docs-llm/Screen Reader Content.md +73 -0
- package/docs-llm/Scroll Container Context.md +155 -0
- package/docs-llm/Scroll.md +152 -0
- package/docs-llm/Search.md +381 -0
- package/docs-llm/Select.md +985 -0
- package/docs-llm/Side Panel.md +777 -0
- package/docs-llm/Slider.md +339 -0
- package/docs-llm/Sliding Panels.md +340 -0
- package/docs-llm/Split Button.md +295 -0
- package/docs-llm/Static Content.md +90 -0
- package/docs-llm/Step Bar.md +292 -0
- package/docs-llm/Switch.md +268 -0
- package/docs-llm/Tab Bar.md +439 -0
- package/docs-llm/Tab Layout.md +398 -0
- package/docs-llm/Table.md +2642 -0
- package/docs-llm/Text Area.md +253 -0
- package/docs-llm/Text.md +339 -0
- package/docs-llm/Tooltip.md +325 -0
- package/docs-llm/Transition Open.md +406 -0
- package/docs-llm/Tree.md +591 -0
- package/docs-llm/Typography.md +125 -0
- package/docs-llm/Wait Spinner.md +121 -0
- package/docs-llm/llms.txt +101 -0
- package/package.json +6 -5
- package/types/src/Box/Box.d.ts +2 -10
- package/types/src/Drawer/Body.d.ts +17 -0
- package/types/src/Drawer/Drawer.d.ts +114 -0
- package/types/src/Drawer/DrawerContext.d.ts +11 -0
- package/types/src/Drawer/Footer.d.ts +25 -0
- package/types/src/Drawer/Header.d.ts +41 -0
- package/types/src/Drawer/docs/examples/Basic.d.ts +6 -0
- package/types/src/Drawer/docs/examples/ContainerPosition.d.ts +7 -0
- package/types/src/Drawer/docs/examples/InitialFocus.d.ts +9 -0
- package/types/src/Drawer/docs/examples/InlinePosition.d.ts +7 -0
- package/types/src/Drawer/docs/examples/PagePosition.d.ts +7 -0
- package/types/src/Drawer/index.d.ts +2 -0
- package/types/src/JSONTree/JSONTree.d.ts +12 -5
- package/types/src/JSONTree/renderTreeItems.d.ts +2 -1
- package/types/src/Menu/Item.d.ts +2 -1
- package/types/src/Menu/docs/examples/SelectableCheckbox.d.ts +7 -0
- package/types/src/Modal/Modal.d.ts +1 -2
- package/types/src/Multiselect/Compact.d.ts +8 -3
- package/types/src/Multiselect/Multiselect.d.ts +8 -3
- package/types/src/Multiselect/Normal.d.ts +8 -3
- package/types/src/Multiselect/Option.d.ts +6 -3
- package/types/src/Multiselect/docs/examples/Disabled.d.ts +1 -0
- package/types/src/Select/Option.d.ts +6 -3
- package/types/src/Select/Select.d.ts +8 -5
- package/types/src/Select/docs/examples/Dimmed.d.ts +7 -0
- package/types/src/SelectBase/OptionBase.d.ts +6 -3
- package/types/src/SelectBase/SelectBase.d.ts +8 -3
- package/types/src/SidePanel/SidePanel.d.ts +43 -2
- package/types/src/SidePanel/docs/examples/DockLayout.d.ts +17 -0
- package/types/src/SidePanel/docs/examples/InitialFocus.d.ts +9 -0
- package/types/src/TransitionOpen/TransitionOpen.d.ts +29 -4
- package/types/src/useKeyPress/index.d.ts +9 -2
- package/types/src/useOnClickOutside/index.d.ts +2 -0
- package/types/src/useOnClickOutside/useOnClickOutside.d.ts +4 -0
- package/useKeyPress.js +23 -18
- package/useOnClickOutside.d.ts +2 -0
- package/useOnClickOutside.js +79 -0
- package/types/src/RadioList/docs/examples/Row.d.ts +0 -6
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Message Bar
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> Image: Illustration of a Message Bar component.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## When to use this component
|
|
10
|
+
To communicate information at the page level. Examples:
|
|
11
|
+
- System level items (expired accounts, server outages)
|
|
12
|
+
- Account status
|
|
13
|
+
|
|
14
|
+
## When to use another component
|
|
15
|
+
- When you need to communicate feedback of actions taken within the page use `Message`.
|
|
16
|
+
|
|
17
|
+
```mermaid
|
|
18
|
+
graph TD
|
|
19
|
+
accDescr: Decision tree that guides on when to use the MessageBar component or something else
|
|
20
|
+
A(Can the message be placed next to the content it refers to?) -- Yes --- B(Message)
|
|
21
|
+
A -- No --- C(Message Bar)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Check out
|
|
25
|
+
- [Message][1]
|
|
26
|
+
|
|
27
|
+
## Behavior
|
|
28
|
+
|
|
29
|
+
### Types
|
|
30
|
+
Choose from four account notification types: Information, Warning, Success, Error
|
|
31
|
+
> Image: Image of four Message Bar components. The first is a information type with the label, Provides helpful feedback/information to the user. More details. The second is a warning type with the label, Warns the user of something that needs their attention. Stop warning. The third is a error type with the label, Informs user of a problem or error, system or user. Fix error. The fourth is a success type with the label, Provides positive feedback/information to the user. More details.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
### Place at the top of pages
|
|
37
|
+
`Message Bar` is used for posting system level messages and should be placed at the top of a page.
|
|
38
|
+
|
|
39
|
+
> Image: Illustration of pages with a Message Bar. The example with heart eyes emoji shows a Message Bar at the top of the page, while the example with grimacing emoji shows the Message Bar nexted inside a page section.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### In other areas, place below heading
|
|
43
|
+
If used in areas other than a page, placing the `Message Bar` below the heading gives users context on what the message is referring to.
|
|
44
|
+
|
|
45
|
+
> Image: Illustration of modals that include a Message Bar. The first example with heart eyes emoji shows the Message Bar placed under the modal title. The second example with grimacing emoji shows the Message Bar placed above the modal title.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Include a dismiss action
|
|
49
|
+
Always consider including a dismiss action.
|
|
50
|
+
|
|
51
|
+
> Image: Illustration of pages with a Message Bar. The example with heart eyes emoji shows a Message Bar with a dismiss button, while the example with grimacing emoji shows a Message Bar without a dismiss button.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Icons
|
|
55
|
+
The icons are used to convey meaning and must not be removed nor changed.
|
|
56
|
+
|
|
57
|
+
> Image: Illustration of pages with a Message Bar. The example with heart eyes emoji shows a Message Bar with an icon, while the example with grimacing emoji shows a Message Bar without an icon.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Don't stack Message Bars
|
|
61
|
+
Stacking of `Message Bar` should be avoided as it removes the one to one relationship a message has with a specific user action. This can create confusion on what is causing the message to be displayed.
|
|
62
|
+
|
|
63
|
+
> Image: The first example with heart eyes emoji shows an illustration of a page with a Message Bar while the second example with grimacing emoji, shows an illustration of a page with multiple Message Bars.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## Content
|
|
67
|
+
|
|
68
|
+
### Be concise
|
|
69
|
+
Keep content direct and concise. Consider using a link within the message bar if you need to provide more robust content.
|
|
70
|
+
|
|
71
|
+
> Image: Illustration of pages with a Message Bar. The first example with heart eyes emoji shows the a Message Bar with a single line of text. The second example with grimacing emoji shows a Message Bar with three lines of text.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
[1]: ./Message
|
|
75
|
+
|
|
76
|
+
## Examples
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Basic
|
|
80
|
+
|
|
81
|
+
Message Bar is a landmark so that users can easily navigate to and discover the important information; therefore, they must include a label using aria-labelledby or aria-label. There are several ways to accomplish this so each of the examples on this page illustrates a different approach.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import React from 'react';
|
|
85
|
+
|
|
86
|
+
import Layout from '@splunk/react-ui/Layout';
|
|
87
|
+
import MessageBar from '@splunk/react-ui/MessageBar';
|
|
88
|
+
import { createDOMID } from '@splunk/ui-utils/id';
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
function Basic() {
|
|
92
|
+
const labelId = createDOMID('messagebar-label');
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<Layout style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
96
|
+
<MessageBar type="info" aria-labelledby={labelId}>
|
|
97
|
+
<span id={labelId}>Account notification:</span> your trial{' '}
|
|
98
|
+
<strong>will expire soon</strong>.
|
|
99
|
+
</MessageBar>
|
|
100
|
+
<MessageBar type="info" aria-label="Account notification">
|
|
101
|
+
Your trial <strong>will expire soon</strong>.
|
|
102
|
+
</MessageBar>
|
|
103
|
+
</Layout>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default Basic;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
### Types
|
|
113
|
+
|
|
114
|
+
Message Bar can have one of four types: "info", "warning", "error" or "success".
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import React from 'react';
|
|
118
|
+
|
|
119
|
+
import Layout from '@splunk/react-ui/Layout';
|
|
120
|
+
import Link from '@splunk/react-ui/Link';
|
|
121
|
+
import MessageBar from '@splunk/react-ui/MessageBar';
|
|
122
|
+
import { createDOMID } from '@splunk/ui-utils/id';
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
function Types() {
|
|
126
|
+
const handleRequestClose = () => {};
|
|
127
|
+
const headingId = createDOMID('account-notifications');
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<section>
|
|
131
|
+
<Layout style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
|
|
132
|
+
<h2 id={headingId}>Account notifications</h2>
|
|
133
|
+
<MessageBar
|
|
134
|
+
type="info"
|
|
135
|
+
aria-labelledby={headingId}
|
|
136
|
+
onRequestClose={handleRequestClose}
|
|
137
|
+
>
|
|
138
|
+
Your trial <strong>will expire soon</strong>. This message should include{' '}
|
|
139
|
+
<Link to="http://duckduckgo.com">inline links</Link> for recovery.
|
|
140
|
+
</MessageBar>
|
|
141
|
+
<MessageBar
|
|
142
|
+
type="warning"
|
|
143
|
+
aria-labelledby={headingId}
|
|
144
|
+
onRequestClose={handleRequestClose}
|
|
145
|
+
>
|
|
146
|
+
Your trial <strong>will expire soon</strong>. This message should include{' '}
|
|
147
|
+
<Link to="http://duckduckgo.com">inline links</Link> for recovery.
|
|
148
|
+
</MessageBar>
|
|
149
|
+
<MessageBar
|
|
150
|
+
type="error"
|
|
151
|
+
aria-labelledby={headingId}
|
|
152
|
+
onRequestClose={handleRequestClose}
|
|
153
|
+
>
|
|
154
|
+
Your trial <strong>will expire soon</strong>. This message should include{' '}
|
|
155
|
+
<Link to="http://duckduckgo.com">inline links</Link> for recovery.
|
|
156
|
+
</MessageBar>
|
|
157
|
+
<MessageBar
|
|
158
|
+
type="success"
|
|
159
|
+
aria-labelledby={headingId}
|
|
160
|
+
onRequestClose={handleRequestClose}
|
|
161
|
+
>
|
|
162
|
+
Your trial <strong>will expire soon</strong>. This message should include{' '}
|
|
163
|
+
<Link to="http://duckduckgo.com">inline links</Link> for recovery.
|
|
164
|
+
</MessageBar>
|
|
165
|
+
</Layout>
|
|
166
|
+
</section>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export default Types;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
### With actions
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
import React from 'react';
|
|
179
|
+
|
|
180
|
+
import Button from '@splunk/react-ui/Button';
|
|
181
|
+
import Layout from '@splunk/react-ui/Layout';
|
|
182
|
+
import MessageBar from '@splunk/react-ui/MessageBar';
|
|
183
|
+
import { createDOMID } from '@splunk/ui-utils/id';
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
function WithActions() {
|
|
187
|
+
const labelId = createDOMID('region-label');
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<MessageBar type="info" aria-labelledby={labelId}>
|
|
191
|
+
<div id={labelId}>
|
|
192
|
+
A message that prompts the user to take action now. Users can dismiss this message
|
|
193
|
+
or take action.
|
|
194
|
+
</div>
|
|
195
|
+
<Layout style={{ marginTop: '8px' }}>
|
|
196
|
+
<Button appearance="primary">Update</Button>
|
|
197
|
+
<Button appearance="secondary">Dismiss</Button>
|
|
198
|
+
</Layout>
|
|
199
|
+
</MessageBar>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export default WithActions;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
## API
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
### MessageBar API
|
|
213
|
+
|
|
214
|
+
#### Props
|
|
215
|
+
|
|
216
|
+
| Name | Type | Required | Default | Description |
|
|
217
|
+
|------|------|------|------|------|
|
|
218
|
+
| children | React.ReactNode | yes | | Text is required and should be concise. |
|
|
219
|
+
| elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
220
|
+
| onRequestClose | React.MouseEventHandler<HTMLButtonElement \| HTMLAnchorElement> | no | | Includes a close button. Always consider including a close button. |
|
|
221
|
+
| type | 'info' \| 'warning' \| 'error' \| 'success' | yes | | Sets the severity of this `MessageBar`. |
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
## Accessibility
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
## Tab Order
|
|
231
|
+
Links and dismiss buttons are interactive elements that can be added to `Message Bar` that change the tab order.
|
|
232
|
+
|
|
233
|
+
> Image: Image of two Multiselect components with interactive elements in a focus state. The first component has a dismiss button while the second component has an inline link and a dismiss button.
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Message
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> Image: Illustration of a Message component.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## When to use this component
|
|
10
|
+
Messages provide feedback, guidance, or alerts directly within the flow of content.
|
|
11
|
+
- To convey information that is relevant to the user's current task or context.
|
|
12
|
+
|
|
13
|
+
## When to use another component
|
|
14
|
+
- When the information being communicated is at the system level, use a `Message Bar`.
|
|
15
|
+
|
|
16
|
+
```mermaid
|
|
17
|
+
graph TD
|
|
18
|
+
accDescr: Decision tree that guides on when to use the Message component or something else
|
|
19
|
+
A(Can the message be placed next to the content it refers to?) -- Yes --- B(Message)
|
|
20
|
+
A -- No --- C(Message Bar)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Check out
|
|
24
|
+
- [Message Bar][1]
|
|
25
|
+
|
|
26
|
+
## Behavior
|
|
27
|
+
|
|
28
|
+
### Types
|
|
29
|
+
Choose from four message types: Information, Warning, Success, Error
|
|
30
|
+
|
|
31
|
+
> Image: Image of four Message components. The first is a information type with the label, Provides helpful feedback/information inline with the content. The second is a warning type with the label, Warns the user of something that needs their attention inline with the content. The third is a error type with the label, Informs user of a problem or error inline with the content. The fourth is a success type with the label, Provides positive feedback/information inline with the content
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Appearance
|
|
36
|
+
#### Default
|
|
37
|
+
The default appearance consists of an icon and a single line of text.
|
|
38
|
+
|
|
39
|
+
> Image: Image of four Message components. The first is a information type with the label, Provides helpful feedback/information inline with the content. The second is a warning type with the label, Warns the user of something that needs their attention inline with the content. The third is a error type with the label, Informs user of a problem or error inline with the content. The fourth is a success type with the label, Provides positive feedback/information inline with the content
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
#### Fill
|
|
43
|
+
The fill appearance consists of a filled box with an icon and text and can also include a title.
|
|
44
|
+
|
|
45
|
+
> Image: Image of four Message components using appearance `fill`. The first is a information type with the label, Provides helpful feedback/information. The second is a warning type with the label, Warns the user of something that needs their attention. The third is a error type with the label, Informs user of a problem or error. The fourth is a success type with the label, Provides positive feedback/information.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
### Icons
|
|
51
|
+
The icons are used to convey meaning and must not be removed nor changed.
|
|
52
|
+
|
|
53
|
+
> Image: Illustration of two default Message components. The example with heart eyes emoji shows the message with an icon, while the example with grimacing emoji shows the message without an icon.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Don't replace other component's error states
|
|
57
|
+
Many components have built-in error messages. Ensure they are being fully utilized before using `Message`.
|
|
58
|
+
|
|
59
|
+
> Image: Illustration of an text input for emails and an error message. The example with heart eyes emoji shows the text input component
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Use filled Messages for larger sections of content
|
|
63
|
+
The appearance used should be appropriate to the size of the content it is regarding to and the importance of the message.
|
|
64
|
+
|
|
65
|
+
> Image: Illustration of pages that are split into one large and two small sections of content. The example with heart eyes emoji shows a Fill Message Component at the top the large content section. The second example with grimacing emoji shows a default Message Component at the top the large content section, that could easily be missed.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### Include a dismiss action for filled Messages
|
|
69
|
+
Messages with filled appearance are more noticeable. Always consider including a dismiss action to allow users to reduce noise.
|
|
70
|
+
|
|
71
|
+
> Image: Illustration of two Messages. The example with heart eyes emoji shows a Message with a title and a paragraph, while the example with grimacing emoji shows a Message without a title and a much longer paragraph.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Content
|
|
75
|
+
|
|
76
|
+
### Add titles to break up content
|
|
77
|
+
When conveying larger messages, titles provide users a way to quickly comprehend the main meaning of the message. Titles should accompany content rather than being used alone. If not including visually including a title, a semantic title still must be added for improved accessibility.
|
|
78
|
+
|
|
79
|
+
> Image: Illustration of two Messages. The first example with heart eyes emoji shows a Message with a single line of text. The second example with grimacing emoji shows a Message with three lines of text.
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
### Keep content direct and concise.
|
|
83
|
+
|
|
84
|
+
> Image: Illustration of two filled Messages with a title and a paragraph. In the first example with heart eyes emoji, the title is user group access updated, and the paragraph is general users can now edit alert logs. In the second example with grimacing emoji, the title is User Group access updated to view alert logs, and the paragraph is The 368 users that are in the general user group can now edit alert logs.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
[1]: ./MessageBar
|
|
88
|
+
|
|
89
|
+
## Examples
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### Message Types
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import React from 'react';
|
|
96
|
+
|
|
97
|
+
import Layout from '@splunk/react-ui/Layout';
|
|
98
|
+
import Message from '@splunk/react-ui/Message';
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function Basic() {
|
|
102
|
+
return (
|
|
103
|
+
<Layout style={{ flexDirection: 'column', alignItems: 'stretch' }}>
|
|
104
|
+
<Message type="info">An info message for the user.</Message>
|
|
105
|
+
<Message type="warning">A warning message for the user.</Message>
|
|
106
|
+
<Message type="error">An error message for the user.</Message>
|
|
107
|
+
<Message type="success">A success message for the user.</Message>
|
|
108
|
+
</Layout>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default Basic;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
### Fill
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import React from 'react';
|
|
121
|
+
|
|
122
|
+
import Layout from '@splunk/react-ui/Layout';
|
|
123
|
+
import Message from '@splunk/react-ui/Message';
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
function Fill() {
|
|
127
|
+
return (
|
|
128
|
+
<Layout style={{ flexDirection: 'column', alignItems: 'stretch' }}>
|
|
129
|
+
<Message appearance="fill" type="info">
|
|
130
|
+
An info message for the user.
|
|
131
|
+
</Message>
|
|
132
|
+
<Message appearance="fill" type="warning">
|
|
133
|
+
A warning message for the user.
|
|
134
|
+
</Message>
|
|
135
|
+
<Message appearance="fill" type="error">
|
|
136
|
+
An error message for the user.
|
|
137
|
+
</Message>
|
|
138
|
+
<Message appearance="fill" type="success">
|
|
139
|
+
A success message for the user.
|
|
140
|
+
</Message>
|
|
141
|
+
</Layout>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default Fill;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### Content
|
|
151
|
+
|
|
152
|
+
Message can contain text, links, and buttons. Interactive items should not be included in content when Message is being used as a toast.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import React from 'react';
|
|
156
|
+
|
|
157
|
+
import Link from '@splunk/react-ui/Link';
|
|
158
|
+
import Message from '@splunk/react-ui/Message';
|
|
159
|
+
import P from '@splunk/react-ui/Paragraph';
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
function Content() {
|
|
163
|
+
return (
|
|
164
|
+
<Message appearance="fill" type="info" onRequestRemove={() => {}}>
|
|
165
|
+
<Message.Title>
|
|
166
|
+
Your trial <strong>will expire soon</strong>.
|
|
167
|
+
</Message.Title>
|
|
168
|
+
<P>
|
|
169
|
+
An info message for the user explaining the trial expiration and what actions they
|
|
170
|
+
may need to take.
|
|
171
|
+
</P>
|
|
172
|
+
<Link to="Overview" appearance="standalone">
|
|
173
|
+
Read more about Splunk UI
|
|
174
|
+
</Link>
|
|
175
|
+
</Message>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default Content;
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
### Removable
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import React from 'react';
|
|
188
|
+
|
|
189
|
+
import Layout from '@splunk/react-ui/Layout';
|
|
190
|
+
import Message from '@splunk/react-ui/Message';
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
function Removable() {
|
|
194
|
+
return (
|
|
195
|
+
<Layout style={{ flexDirection: 'column', alignItems: 'stretch' }}>
|
|
196
|
+
<Message appearance="fill" type="info" onRequestRemove={() => {}}>
|
|
197
|
+
An info message for the user.
|
|
198
|
+
</Message>
|
|
199
|
+
<Message appearance="fill" type="warning" onRequestRemove={() => {}}>
|
|
200
|
+
A warning message for the user.
|
|
201
|
+
</Message>
|
|
202
|
+
<Message appearance="fill" type="error" onRequestRemove={() => {}}>
|
|
203
|
+
An error message for the user.
|
|
204
|
+
</Message>
|
|
205
|
+
<Message appearance="fill" type="success" onRequestRemove={() => {}}>
|
|
206
|
+
A success message for the user.
|
|
207
|
+
</Message>
|
|
208
|
+
</Layout>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export default Removable;
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
## API
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
### Message API
|
|
222
|
+
|
|
223
|
+
#### Props
|
|
224
|
+
|
|
225
|
+
| Name | Type | Required | Default | Description |
|
|
226
|
+
|------|------|------|------|------|
|
|
227
|
+
| appearance | 'default' \| 'fill' | no | 'default' | Changes the style of the Message. |
|
|
228
|
+
| children | React.ReactNode | no | | |
|
|
229
|
+
| elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
230
|
+
| onRequestRemove | React.MouseEventHandler<HTMLButtonElement \| HTMLAnchorElement> | no | | Includes a remove button if set. Only set this prop when using the `fill` appearance. |
|
|
231
|
+
| type | 'info' \| 'warning' \| 'error' \| 'success' | no | 'warning' | Sets the severity or type of this `Message`. |
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
### Message.Title API
|
|
236
|
+
|
|
237
|
+
A title component for use in `Message`.
|
|
238
|
+
|
|
239
|
+
#### Props
|
|
240
|
+
|
|
241
|
+
| Name | Type | Required | Default | Description |
|
|
242
|
+
|------|------|------|------|------|
|
|
243
|
+
| children | React.ReactNode | no | | |
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|