A dialog box (Dialog
) is a temporary pop-up that takes focus from the page or app and requires people to interact with it. It’s primarily used for confirming actions, such as deleting a file, or asking people to make a choice.
For more details and examples visit the official docs. The R package can not handle each and every case, so for advanced use cases you need to work using the original docs to achieve the desired result.
Dialog(...)
DialogFooter(...)
string
Label to be passed to to aria-label of close button
string
The classname for when the header is draggable
boolean
Is inside a multiline wrapper
ResponsiveMode
Responsive mode passed in from decorator.
boolean
Show an 'x' close button in the upper-right corner
string
The Id for subText container
string
The Id for title container
React.HTMLAttributes<HTMLDivElement>
The props for title container.
string
Optional id for aria-DescribedBy
string
Optional id for aria-LabelledBy
string
Optional class name to be added to the root class
IRefObject<IDialog>
Optional callback to access the IDialog interface. Use this instead of ref for accessing the public methods and properties of the component.
string
Optional override for container class
string
Optional override content class
IDialogContentProps
Props to be passed through to Dialog Content
boolean
Whether the dialog is hidden.
boolean
Whether the dialog can be light dismissed by clicking outside the dialog (on the overlay).
boolean
Whether the overlay is dark themed.
boolean
Whether the dialog is displayed. Deprecated, use hidden
instead.
ICSSRule | ICSSPixelUnitRule
Sets the maximum width for the dialog. It limits the width property to be larger than the value specified in max-width.
ICSSRule | ICSSPixelUnitRule
Sets the minimum width of the dialog. It limits the width property to be not smaller than the value specified in min-width.
IModalProps
Props to be passed through to Modal
(ev?: React.MouseEvent<HTMLButtonElement>) => any
A callback function for when the Dialog is dismissed from the close button or light dismiss. Can also be specified separately in content and modal.
() => any
A callback function which is called after the Dialog is dismissed and the animation is complete.
() => void
A callback function for when the Dialog content is mounted on the overlay layer
() => void
Deprecated at 0.81.2, use onLayerDidMount
instead.
IStyleFunctionOrObject<IDialogStyleProps, IDialogStyles>
Call to provide customized styling that will layer on top of the variant rules
string
The subtext to display in the dialog.
ITheme
Theme provided by HOC.
string | JSX.Element
The title text to display at the top of the dialog.
IButtonProps[]
Other top buttons that will show up next to the close button
DialogType
The type of Dialog to display.
Don't use more than three buttons.
Dialog boxes consist of a header, body, and footer.
Validate that people’s entries are acceptable before closing the dialog box. Show an inline validation error near the field they must correct.
Blocking dialogs should be used very sparingly, only when it is critical that people make a choice or provide information before they can proceed. Blocking dialogs are generally used for irreversible or potentially destructive tasks. They’re typically paired with an overlay without a light dismiss.
Locks to the top of the dialog.
May include an icon to the left of the title.
Includes a Close button in the top-right corner.
Keep the title as concise as possible.
Don’t use periods at the end of titles.
This mandatory content should explain the main information in a clear, concise, and specific statement or question. For example, “Delete this file?” instead of “Are you sure?”
The title shouldn’t be a description of the body content. For example, don’t use “Error” as a title. Instead, use an informative statement like “Your session ended.”
Use sentence-style capitalization—only capitalize the first word. For more info, see Capitalization in the Microsoft Writing Style Guide.
Don't restate the title in the body.
Use ending punctuation on sentences.
Use actionable language, with the most important information at the beginning.
Use the optional body content area for additional info or instructions, if needed. Only include information needed to help people make a decision.
Write button labels that are specific responses to the main information in the title. The title “Delete this file?” could have buttons labeled “Delete” and “Cancel”.
Be concise. Limit labels to one or two words. Usually a single verb is best. Include a noun if there is any room for interpretation about what the verb means. For example, “Delete” or “Delete file”.
library(shiny.fluent)
if (interactive()) {
shinyApp(
ui = div(
DefaultButton.shinyInput("showDialog", text = "Open dialog"),
reactOutput("reactDialog")
),
server = function(input, output) {
isDialogOpen <- reactiveVal(FALSE)
output$reactDialog <- renderReact({
dialogContentProps <- list(
type=0,
title='Missing Subject',
closeButtonAriaLabel='Close',
subText='Do you want to send this message without a subject?'
)
Dialog(
hidden = !isDialogOpen(),
onDismiss = JS("function() { Shiny.setInputValue('hideDialog', Math.random()); }"),
dialogContentProps = dialogContentProps,
modalProps = list(),
DialogFooter(
PrimaryButton.shinyInput("dialogSend", text = "Send"),
DefaultButton.shinyInput("dialogDontSend", text = "Don't send")
)
)
})
observeEvent(input$showDialog, isDialogOpen(TRUE))
observeEvent(input$hideDialog, isDialogOpen(FALSE))
observeEvent(input$dialogSend, isDialogOpen(FALSE))
observeEvent(input$dialogDontSend, isDialogOpen(FALSE))
}
)
}