Vue A11yDialog
This is a Vue.js wrapper component for a11y-dialog@5.2.0.
Install
Usage
In your main.js
application file, install the component:
Then use it as follows:
It's important to assign the direct reference to the dialog instance via @dialog-ref
, otherwise there is no way to call its methods.
Alternatively, you can also import the component directly into your file without installing it first:
API
All
a11y-dialog
instance methods are available, see their docs for more.
disable-native
- Property:
disable-native
- Type:
Boolean
- Default:
false
- Description: Per default we're using the native
<dialog>
element. However, if you want to disable that and use a<div role="dialog">
instead, you can just do that by adding this attribute. This gives you full control (and responsibilites) over styling. Read thea11y-dialog
Styling layer documentation for more information. - Usage:
id
- Property:
id
- Type:
String
- Required:
true
- Description: The unique HTML
id
attribute added to the dialog element, internally used by a11y-dialog to manipulate the dialog. - Usage:
app-root
- Property:
appRoot
- Type:
String
,Array<String>
— CSS Selector string. - Required:
true
- Description: The selector(s)
a11y-dialog
needs to disable when the dialog is open. - Usage:
class-names
- Property:
class-names
- Type:
Object
- Required:
false
- Default:
{}
- Description: Object of classes for each HTML element of the dialog element. Keys are:
base
,overlay
,element
,document
,title
,closeButton
. See a11y-dialog docs for reference. - Usage:
title-id
- Property:
titleId
- Type:
String
- Required:
false
- Default: Defaults to
id + '-title'
. - Description: The HTML
id
attribute of the dialog’s title element, used by assistive technologies to provide context and meaning to the dialog window. - Usage:
close-button-label
- Property:
closeButtonLabel
- Type:
String
- Required:
false
- Default:
'Close this dialog window'
- Description: The HTML
aria-label
attribute of the close button, used by assistive technologies to provide extra meaning to the usual cross-mark. - Usage:
role
- Property:
role
- Type:
String
- Required:
false
- Default:
dialog
- Description: The
role
attribute of the dialog element, eitherdialog
(default) oralertdialog
to make it a modal (preventing closing on click outside of ESC key). - Usage:
Events
dialog-ref
- Returns: An
a11y-dialog
instance orundefined
. - Description: This event emits the
a11y-dialog
instance once the component has been initialised. When it getsdestroyed
, the event returnsundefined
. This is needed to call instance methods of the dialog, e.g.this.dialog.show()
. - Usage:
Slots
title
- Name:
title
- Default:
\u00D7
(×) - Description: The title of the dialog, mandatory in the document to provide context to assistive technology. Could be hidden with CSS (while remaining accessible).
- Usage:
closeButtonContent
- Name:
closeButtonLabel
- Default:
\u00D7
(×) - Description: The string that is the inner HTML of the close button.
- Usage:
Server-side Rendering
This is a client-only component; a11y-dialog
won't render anything on the server and wait for your bundle to be executed on the client.