Changes from V9:
Pass the id of the element that should receive focus when the modal is closed.
Include the subscription if you want the modal to dismiss on Esc.
Modals should allow the user to tab forwards & backwards through the modal content. The user should never find their Focus lost behind the modal backdrop!
Use the FocusManager to tag the focusable elements in your modal, so that we
know to which element to return focus when the user reaches the last focusable element.
import Html.Styled exposing (text)
import Nri.Ui.Modal.V10 as Modal
type Msg
= ModalMsg Modal.Msg
...
viewModal : Modal.Model -> Html Msg
viewModal modalState =
Modal.info
{ title = "Modal Title"
, wrapMsg = ModalMsg
, focusManager =
Modal.OneFocusableElement
(\{ onlyFocusableElement, closeButton } ->
{ content =
[ closeButton onlyFocusableElement
, text "Modal Content"
]
, footer = []
}
)
}
[ Modal.hideTitle
, Modal.css [ padding (px 10) ]
]
modalState