| Name |
Type |
Default value |
Description |
|---|
| AbsolutePosition |
bool |
false |
When true, the Modal is positioned absolute instead of fixed, so that it covers the element it was declared inside of rather than the screen. That element has to establish a containing block of its own (position: relative). |
| AriaModal |
bool |
true |
Whether the Modal should be announced as modal to assistive technologies. It is also what decides whether the Modal keeps the keyboard inside itself: a Modal that is not announced as modal leaves the page behind it reachable with the keyboard the way it is reachable with the pointer. |
| AutoToggleScroll |
bool |
false |
Enables the auto scrollbar toggle behavior of the Modal, which takes the overflow off the scroller while it is open and hands it back once it closes. A Modal that does this holds its own scroller, so the hold it would otherwise take on the page is stood down for it. The scroller is the one named by ScrollerElement or ScrollerSelector, then the one of the BitAppShell the Modal is inside of, and the page when it is inside none. |
| Blocking |
bool |
false |
When enabled, prevents the Modal from being light dismissed by clicking outside the Modal (on the overlay). Escape still dismisses it unless NoDismissOnEscape is set as well. |
| Body |
RenderFragment? |
null |
The content of the body section of the Modal, the alias of ChildContent, which it takes precedence over. This is what a Modal that also declares a Header or a Footer uses to keep the three of them side by side. |
| ChildContent |
RenderFragment? |
null |
The content of the Modal, it can be any custom tag or text. |
| Classes |
BitModalClassStyles? |
null |
Custom CSS classes for different parts of the BitModal component. |
| CloseButtonTitle |
string? |
null |
The title (and aria-label) of the close button for accessibility and localization. Defaults to "Close" when not set. |
| CloseIcon |
BitIconInfo? |
null |
The icon of the close button, provided as custom CSS classes of an external icon library. Takes precedence over CloseIconName when both are set. |
| CloseIconName |
string? |
null |
The name of the icon of the close button, from the built-in Fluent UI icons. Defaults to Cancel when not set. |
| DefaultIsOpen |
bool? |
null |
The initial opening state of the Modal in the uncontrolled mode, which is when the IsOpen parameter is not set. |
| DragElementSelector |
string? |
null |
The CSS selector of the drag element, which is the content of the Modal by default. Ignored by a Modal that is not Draggable. |
| Draggable |
bool |
false |
Whether the Modal can be dragged around. |
| Footer |
RenderFragment? |
null |
The template used to render the footer section of the Modal. |
| FooterText |
string? |
null |
The text of the footer section of the Modal. |
| FullHeight |
bool |
false |
Makes the Modal height 100% of its parent container. |
| FullSize |
bool |
false |
Makes the Modal width and height 100% of its parent container, which is FullWidth and FullHeight in one parameter. |
| FullWidth |
bool |
false |
Makes the Modal width 100% of its parent container. |
| Header |
RenderFragment? |
null |
The template used to render the header section of the Modal. Takes precedence over HeaderText when both are set. |
| HeaderText |
string? |
null |
The text of the header section of the Modal. |
| Height |
string? |
null |
The CSS height of the Modal (any CSS length). A Modal is as tall as its content when this is not set. It is written as an inline style on the content box, so it takes precedence over FullHeight, and it is capped by MaxHeight - or, when that is not set either, by the height of the screen. |
| IsAlert |
bool? |
null |
Determines the ARIA role of the Modal (alertdialog/dialog). A Blocking Modal that is not Modeless announces itself as an alertdialog when this is not set, since a surface that refuses to be dismissed by a click outside of it is one waiting to be answered. |
| IsOpen |
bool |
false |
Whether the Modal is displayed. |
| KeepMounted |
bool |
false |
Keeps the Modal in the page while it is closed instead of taking it out and building it again the next time it opens, so the content - and whatever state it holds - survives being closed. Nothing is rendered before the first time the Modal opens, and a kept Modal is inert and hidden from assistive technologies while it is closed. |
| MaxHeight |
string? |
null |
The CSS height the Modal is not to grow past, however long its content is (any CSS length). The height of the screen is the cap when this is not set, which is what keeps a Modal longer than the screen reachable: it scrolls inside itself rather than running off both ends of the page. |
| MaxWidth |
string? |
null |
The CSS width the Modal is not to grow past, however wide its content is (any CSS length). The width of the screen is the cap when this is not set, which leaves a Modal as wide as its content - and on a wide screen that can be a line of text too long to read comfortably. |
| ModeFull |
bool |
false |
Renders the overlay in full mode that gives it an opaque background. The overlay catches the clicks meant for the page behind it either way; this is what makes it dim that page as well. |
| Modeless |
bool |
false |
Whether the Modal should be modeless (e.g. not dismiss when focusing/clicking outside of the Modal). If true: Blocking is ignored, there is no overlay, and the Modal neither reports itself modal nor holds the keyboard or the page. |
| NoAutoFocus |
bool |
false |
Prevents the Modal from moving the focus into itself when it opens. By default the focus lands on the first focusable element of the content, or on the element inside it marked with the data-autofocus attribute, or on the content itself when it holds nothing focusable. |
| NoBorder |
bool |
false |
Removes the default top border of the Modal. |
| NoDismissOnEscape |
bool |
false |
Prevents the Modal from being dismissed by pressing the Escape key. |
| NoFocusTrap |
bool |
false |
Prevents the Modal from keeping the keyboard focus inside itself while it is open. The trap is only set up for a Modal that reports itself modal (see AriaModal) in the first place. |
| NoRestoreFocus |
bool |
false |
Prevents the Modal from handing the focus back to the element that had it before the Modal opened. The focus is only handed back when nothing else has taken it in the meantime. |
| NoScrollLock |
bool |
false |
Prevents the Modal from holding the page still while it is open. By default the page behind an open Modal is held, with the room the scrollbar took added back as padding so that nothing shifts sideways; the holds are counted, so the page is only handed back once the last open Modal closes. A Modeless Modal never holds the page in the first place, and a Modal that toggles the scroll itself (see AutoToggleScroll) holds its scroller instead. The gestures that land on a Modal that leaves the page scrolling are handed to the scroller behind it - the one ScrollerElement or ScrollerSelector names, or the application shell's - since the layer the Modal is drawn in is fixed to the viewport, where the wheel would else reach a document that does not scroll. |
| OnDismiss |
EventCallback<MouseEventArgs> |
|
A callback function for when the Modal is dismissed. |
| OnEscapeKeyDown |
EventCallback<KeyboardEventArgs> |
|
A callback function for when the Escape key is pressed inside the Modal. It is invoked for every Escape, including the ones a Modal with NoDismissOnEscape refuses to be dismissed by, which makes it the counterpart of OnOverlayClick for the keyboard. |
| OnOpen |
EventCallback |
|
A callback function for when the Modal is opened, invoked after it has rendered and its focus handling has run. |
| OnOverlayClick |
EventCallback<MouseEventArgs> |
|
A callback function for when somewhere on the overlay element of the Modal is clicked. It is invoked for every overlay click, including the ones a Blocking Modal refuses to be dismissed by. |
| Position |
BitPosition? |
null |
Position of the Modal on the screen. The Modal sits in the middle of the area it covers when this is not set. |
| ScrollerElement |
ElementReference? |
null |
The element reference of the scroller the Modal holds while it is open. Takes precedence over ScrollerSelector and over the scroller a BitAppShell cascades, and is read by both holds: the one the Modal takes by default and the overflow toggle of AutoToggleScroll. |
| ScrollerSelector |
string? |
null |
The CSS selector of the element whose scrolling the Modal holds while it is open. A Modal inside a BitAppShell holds the shell's scroller without being told to, since the shell cascades it; the page (body) is what is held when there is no shell and this is not set. Any other layout that scrolls a region of its own names that region here, since holding a page that never scrolls holds nothing. |
| ShowCloseButton |
bool |
false |
Shows the close button of the Modal, which closes it without a handler of its own. |
| Styles |
BitModalClassStyles? |
null |
Custom CSS styles for different parts of the BitModal component. |
| SubtitleAriaId |
string? |
null |
ARIA id for the subtitle of the Modal, if any. |
| TitleAriaId |
string? |
null |
ARIA id for the title of the Modal, if any. |
| Width |
string? |
null |
The CSS width of the Modal (any CSS length). A Modal is as wide as its content when this is not set. It is written as an inline style on the content box, so it takes precedence over FullWidth, and it is capped by MaxWidth - or, when that is not set either, by the width of the screen. |