You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
react-a11y-dialog is a React component for [a11y-dialog](https://github.com/edenspiekermann/a11y-dialog) relying on [React portals](https://reactjs.org/docs/portals.html) to ease the use of accessible dialog windows in React applications.
3
+
react-a11y-dialog is a React component for [a11y-dialog](https://github.com/edenspiekermann/a11y-dialog) relying on [React portals](https://reactjs.org/docs/portals.html) to ease the use of accessible dialog windows in React applications. This component does not render anything on the server, and waits for the client bundle to kick in to render the dialog through the React portal.
This is a fork of [Hugo Giraudel's](https://github.com/HugoGiraudel/react-a11y-dialog) project ported over to TypeScript and includes any minor changes/improvements I needed. Version 1.0.0 of this project is the equivalent of what would be react-a11y-dialog 4.1.1, meaning this project can be a drop in replacement.
6
+
7
+
## Changes in this Fork
8
+
9
+
- Includes TypeScript definition file
10
+
- Added new `onClose()` callback to the `Dialog` component to allow for notifications of when a dialog was closed.
6
11
7
12
## Install
8
13
9
14
```
10
-
npm install --save react-a11y-dialog
15
+
npm install --save @allejo/react-a11y-dialog
11
16
```
12
17
13
-
## API
14
-
15
-
***Property name**: `id`
16
-
***Type**: string
17
-
***Mandatory**: true
18
-
***Default value**: —
19
-
***Description**: The HTML `id` attribute of the dialog element, internally used by a11y-dialog to manipulate the dialog.
20
-
21
-
---
22
-
23
-
***Property name**: `title`
24
-
***Type**: string | element
25
-
***Mandatory**: true
26
-
***Default value**: —
27
-
***Description**: The title of the dialog, mandatory in the document to provide context to assistive technology. Could be [hidden with CSS](https://hugogiraudel.com/2016/10/13/css-hide-and-seek/) (while remaining accessible).
28
-
29
-
---
30
-
31
-
***Property name**: `dialogRef`
32
-
***Type**: function
33
-
***Mandatory**: false
34
-
***Default value**: no-op
35
-
***Description**: A function called when the component has mounted, receiving the [instance of A11yDialog](http://edenspiekermann.github.io/a11y-dialog/#js-api) so that it can be programmatically accessed later on.
36
-
37
-
---
38
-
39
-
***Property name**: `appRoot`
40
-
***Type**: string | string[]
41
-
***Mandatory**: true
42
-
***Default value**: —
43
-
***Description**: The [selector(s) a11y-dialog need](http://edenspiekermann.github.io/a11y-dialog/#javascript-instantiation) to disable when the dialog is open.
44
-
45
-
---
46
-
47
-
***Property name**: `dialogRoot`
48
-
***Type**: string
49
-
***Mandatory**: true
50
-
***Default value**: —
51
-
***Description**: The container for the dialog to be rendered into ([React portal](https://reactjs.org/docs/portals.html)’s root).
52
-
53
-
---
54
-
55
-
***Property name**: `titleId`
56
-
***Type**: string
57
-
***Mandatory**: false
58
-
***Default value**: `${this.props.id}-title`
59
-
***Description**: The HTML `id` attribute of the dialog’s title element, used by assistive technologies to provide context and meaning to the dialog window.
60
-
61
-
---
62
-
63
-
***Property name**: `closeButtonLabel`
64
-
***Type**: string
65
-
***Mandatory**: false
66
-
***Default value**: “Close this dialog window”
67
-
***Description**: The HTML `aria-label` attribute of the close button, used by assistive technologies to provide extra meaning to the usual cross-mark.
68
-
69
-
---
70
-
71
-
***Property name**: `closeButtonContent`
72
-
***Type**: string | element
73
-
***Mandatory**: false
74
-
***Default value**: `\u00D7` (×)
75
-
***Description**: The string that is the inner HTML of the close button.
76
-
77
-
---
78
-
79
-
***Property name**: `classNames`
80
-
***Type**: object
81
-
***Mandatory**: false
82
-
***Default value**: {}
83
-
***Description**: Object of classes for each HTML element of the dialog element. Keys are: `base`, `overlay`, `element`, `document`, `title`, `closeButton`. See [a11y-dialog docs](http://edenspiekermann.github.io/a11y-dialog/#expected-dom-structure) for reference.
84
-
85
-
---
86
-
87
-
***Property name**: `useDialog`
88
-
***Type**: boolean
89
-
***Mandatory**: false
90
-
***Default value**: `true`
91
-
***Description**: Whether to render a `<dialog>` element or a `<div>` element.
92
-
93
-
---
94
-
95
-
***Property name**: `role`
96
-
***Type**: string
97
-
***Mandatory**: false
98
-
***Default value**: `dialog`
99
-
***Description**: The `role` attribute of the dialog element, either `dialog` (default) or `alertdialog` to make it a modal (preventing closing on click outside of <kbd>ESC</kbd> key).
100
-
101
-
## Server-side rendering
102
-
103
-
react-a11y-dialog does not render anything on the server, and waits for the client bundle to kick in to render the dialog through the React portal.
0 commit comments