Dialog
A dialog differs from a modal in that it does not come with a masking layer (to obscure the rest of the page) and the user can choose to shift focus away from the dialog contents via mouse click or a keyboard shortcut.
If you decide to provide a header inside your dialog, it's recommended to configure the aria-labelledby
attribute, which can be added to props.dialogProps
.
Installation
npm i boundless-dialog --save
Then use it like:
/** @jsx createElement */ import createElement PureComponent from 'react';import findDOMNode from 'react-dom';import Button from 'boundless-button';import Dialog from 'boundless-dialog'; state = showDialog: false { const node = ; this; } { this; } { if thisstateshowDialog return <Dialog = = = => <iframe ='dialog-demo-video-frame' ='560' ='315' ='https://www.youtube.com/embed/HEheh1BH34Q?autoplay=1&showinfo=0&autohide=1' ='0' ='A youtube video showcasing the relative size of celestial objects.' /> <Button ='dialog-demo-close-button' ='Close' = /> </Dialog> ; } { return <div> <Button ='trigger' =>Launch Video</Button> this </div> ; }
Dialog can also just be directly used from the main Boundless library. This is recommended when you're getting started to avoid maintaining the package versions of several components:
npm i boundless --save
the ES6 import
statement then becomes like:
;
Props
Note: only top-level props are in the README, for the full list check out the website.
Required Props
There are no required props.
Optional Props
-
*
· any React-supported attributeExpects Default Value any
n/a
-
after
· arbitrary content to be rendered after the dialog in the DOMExpects Default Value any renderable
null
-
before
· arbitrary content to be rendered before the dialog in the DOMExpects Default Value any renderable
null
-
captureFocus
· determines if focus is allowed to move away from the dialogExpects Default Value bool
true
-
closeOnEscKey
· enable detection of "Escape" keypresses to triggerprops.onClose
; if a function is provided, the return value determines if the dialog will be closedExpects Default Value bool or function
false
-
closeOnInsideClick
· enable detection of clicks inside the dialog area to triggerprops.onClose
; if a function is provided, the return value determines if the dialog will be closedExpects Default Value bool or function
false
-
closeOnOutsideClick
· enable detection of clicks outside the dialog area to triggerprops.onClose
; if a function is provided, the return value determines if the dialog will be closedExpects Default Value bool or function
false
-
closeOnOutsideFocus
· enable detection of focus outside the dialog area to triggerprops.onClose
; if a function is provided, the return value determines if the dialog will be closedExpects Default Value bool or function
false
-
closeOnOutsideScroll
· enable detection of scroll and mousewheel events outside the dialog area to triggerprops.onClose
; if a function is provided, the return value determines if the dialog will be closedExpects Default Value bool or function
false
-
component
· override the type of.b-dialog-wrapper
HTML elementExpects Default Value string
'div'
-
dialogComponent
· override the type of.b-dialog
HTML elementExpects Default Value string
'div'
-
dialogProps
Expects Default Value object
{}
-
onClose
· a custom event handler that is called to indicate that the dialog should be unrendered by its parent; the event occurs if one or more of the "closeOn" props (closeOnEscKey
,closeOnOutsideClick
, etc.) are passed astrue
and the dismissal criteria are satisfiedExpects Default Value function
() => {}
Reference Styles
Stylus
You can see what variables are available to override in variables.styl.
// Redefine any variables as desired, e.g:color-accent = royalblue // Bring in the component styles; they will be autoconfigured based on the above@require "node_modules/boundless-dialog/style"
CSS
If desired, a precompiled plain CSS stylesheet is available for customization at /build/style.css
, based on Boundless's default variables.