Utilities
Overlay
Overlay covers the page - or, positioned absolutely, one container of it - and hosts whatever is placed in it over everything else: a loader, a message, a surface of your own. A click on the layer or Escape dismisses it unless it is blocking, it can dim what it covers, place its content, hold the scroller behind it still, and be driven by binding or by methods.
Notes
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Position
Dismissal
Try to close me
AbsolutePosition
Report
Scroll lock
Events
Programmatic control
Cascading parameters
Style & Class
RTL
CSS variables
The public custom properties this component reads off its root, for what no parameter covers.
Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property:
set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it,
or on the Style of one instance to restyle that one alone. Leave a variable unset and the component falls back to the theme token beside it.
BitOverlay CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-Overlay-z-index | --bit-zin-overlay | Stacking order of an Overlay fixed to the screen. The ZIndex parameter wins over it. |
| --bit-Overlay-background | --bit-clr-bg-overlay | Fill of the layer in ModeFull. |
| --bit-Overlay-backdrop-filter | none | Filter over what the layer covers, e.g. blur(4px) for a frosted layer. |
| --bit-Overlay-padding | 0px | Room kept between the content and the edges of the layer. |
| --bit-Overlay-transition-duration | --bit-mot-duration-short | How long the layer takes to fade in and out. The default collapses under reduced motion; a value set here does not. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitOverlay parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AbsolutePosition | bool | false | Covers the element the Overlay is declared in (which needs position: relative) instead of the screen, taking its rounded corners. |
| AutoToggleScroll | bool | false | Stops the scroller behind the Overlay while it is open, without a layout shift, and hands it back once the last Overlay holding it closes. The scroller is ScrollerElement, then ScrollerSelector, then the scroller of the BitAppShell the Overlay is in, then the page (body). |
| Blocking | bool | false | Keeps the Overlay open on a click on the layer and on Escape. The click is still reported through OnClick. |
| ChildContent | RenderFragment? | null | The content of the Overlay. A click on it never closes the Overlay. |
| DefaultIsOpen | bool? | null | The state an uncontrolled Overlay (IsOpen not set) starts in. |
| IsOpen | bool | false | Whether the Overlay is shown; bindable, so a dismissal is reported back. A closed Overlay is inert, even while it fades out. |
| ModeFull | bool | false | Dims what the Overlay covers with the theme's overlay color (--bit-Overlay-background). The layer is transparent otherwise. |
| NoDismissOnEscape | bool | false | Keeps the Overlay open on Escape, while a click on the layer still closes it. |
| OnClick | EventCallback<MouseEventArgs> | Called for every click on an open Overlay - its content and the clicks a Blocking Overlay refuses included - before it closes. | |
| OnClose | EventCallback | Called once the Overlay has closed, however it was closed, after the scroller it held has been handed back. | |
| OnOpen | EventCallback | Called once the Overlay has opened, however it was opened, after the scroller it holds has been taken. | |
| Position | BitPosition? | null | Where the content is placed on the layer. The content stretches over the whole layer when it is not set. |
| ScrollerElement | ElementReference? | null | The scroller AutoToggleScroll stops, for one a selector cannot name. Wins over ScrollerSelector. |
| ScrollerSelector | string? | null | The CSS selector of the scroller AutoToggleScroll stops. An Overlay that leaves it scrolling hands it the wheel and the touch drag it catches. |
| ZIndex | int? | null | The stacking order of the Overlay, over the shared overlay layer (--bit-Overlay-z-index). |
BitOverlay public members
| Name | Type | Default value | Description |
|---|---|---|---|
| Open | Task | Opens the Overlay, unless it is disabled. | |
| Close | Task | Closes the Overlay, even a disabled one. | |
| Toggle | Task | Opens the Overlay when it is closed, and closes it when it is open. |
BitComponentBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLabel | string? | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | string? | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | BitDir? | null | Gets or sets the text directionality for the component's content. |
| Disabled | bool | false | Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction. |
| ForceAnimation | bool | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| Style | string? | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | string? | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | BitVisibility | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
BitComponentBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | ElementReference | Gets the reference to the root HTML element associated with this component. |
BitPosition enum
| Name | Value | Description |
|---|---|---|
| TopLeft | 0 | The top left corner, in both reading directions. |
| TopCenter | 1 | The top edge, centered horizontally. |
| TopRight | 2 | The top right corner, in both reading directions. |
| TopStart | 3 | The top edge, on the side the reading direction starts from. |
| TopEnd | 4 | The top edge, on the side the reading direction ends at. |
| CenterLeft | 5 | The left edge, centered vertically, in both reading directions. |
| Center | 6 | Centered both ways. |
| CenterRight | 7 | The right edge, centered vertically, in both reading directions. |
| CenterStart | 8 | Centered vertically, on the side the reading direction starts from. |
| CenterEnd | 9 | Centered vertically, on the side the reading direction ends at. |
| BottomLeft | 10 | The bottom left corner, in both reading directions. |
| BottomCenter | 11 | The bottom edge, centered horizontally. |
| BottomRight | 12 | The bottom right corner, in both reading directions. |
| BottomStart | 13 | The bottom edge, on the side the reading direction starts from. |
| BottomEnd | 14 | The bottom edge, on the side the reading direction ends at. |
BitVisibility enum
| Name | Value | Description |
|---|---|---|
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
BitDir enum
| Name | Value | Description |
|---|---|---|
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.