# Callout
**Also known as:** Popover, Popup
## Description
Callout is an anchored surface that hosts any content - a tip, a form, a filter panel, a menu - next to an anchor of its own, next to any element on the page, or at a point a right-click happened, without blocking what is behind it. It places itself where there is room, on the side and the alignment asked for wherever they fit, points at its anchor with an optional arrow, and keeps following it for as long as it is open. It opens on a click or on hover and closes on an outside click or the Escape key, and it can take the keyboard over, dim the page behind it, nest inside another callout, and become a swipeable panel on the small screens.
## Parameters
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| Alignment | `BitCalloutAlignment?` | null | How the callout is lined up with its anchor along the axis it is not placed on. It defaults to Start. |
| AlignmentOffset | `int` | 0 | The distance in pixels the callout is slid along the axis it is aligned on, inwards from the edge of the anchor the Alignment lined it up with. A centered callout has no edge for it to run from. |
| Anchor | `RenderFragment?` | null | The content of the anchor element of the callout. The anchor is rendered as a plain container, so the content given here should hold the focusable element the user activates. |
| AnchorEl | `Func<ElementReference>?` | null | The setter function for element reference to the external anchor element. |
| AnchorId | `string?` | null | The id of the external anchor element. |
| ArrowPadding | `int?` | null | The distance in pixels the arrow drawn by ShowArrow is kept away from the corners of the callout, so that the rounding never cuts it. It defaults to 16, and never drops below the size of the arrow itself. |
| ArrowSize | `int?` | null | The size in pixels of the arrow drawn by ShowArrow, which is the length of the side of the square the beak is cut out of. It defaults to 12. |
| AutoClose | `bool` | false | Closes the callout as soon as a click lands anywhere inside it. |
| AutoFocus | `bool` | false | Moves the focus into the callout as soon as it opens, to its first focusable element, or to the callout itself when it holds none. |
| Background | `BitColorKind?` | null | The color kind of the background of the callout. |
| Border | `BitColorKind?` | null | The color kind of the border of the callout. |
| ChildContent | `RenderFragment?` | null | The content of the callout. |
| Classes | `BitCalloutClassStyles?` | null | Custom CSS classes for different parts of the callout. |
| CollisionPadding | `int` | 0 | The distance in pixels the callout keeps from the edges of the screen when it is placed and when it is slid back onto it. |
| Content | `RenderFragment?` | null | Alias for ChildContent. |
| DefaultIsOpen | `bool?` | null | The initial opening state of the callout in the uncontrolled mode, which is when the IsOpen parameter is not set. |
| Direction | `BitDropDirection?` | null | Determines the allowed directions in which the callout should decide to be opened. |
| FixedCalloutWidth | `bool` | false | Holds the callout to the width of its anchor, so that a content wider than the anchor wraps inside it instead of stretching it. |
| Footer | `RenderFragment?` | null | The content of a footer that stays at the bottom of the callout while the rest of it scrolls. |
| FooterId | `string?` | null | The id of the footer element that renders at the end of the scrolling container of the callout content. It wins over the Footer parameter. |
| Gap | `int` | 0 | The distance in pixels between the anchor and the callout, on whichever side the callout ends up being placed. |
| Header | `RenderFragment?` | null | The content of a header that stays at the top of the callout while the rest of it scrolls. |
| HeaderId | `string?` | null | The id of the header element that renders at the top of the scrolling container of the callout content. It wins over the Header parameter. |
| HoverCloseDelay | `int` | 150 | The delay in milliseconds before the callout closes once the pointer leaves the callout and its anchor in the OpenOnHover mode. |
| HoverOpenDelay | `int` | 0 | The delay in milliseconds before the callout opens once the pointer enters the anchor in the OpenOnHover mode. |
| IsOpen | `bool` | false | Determines the opening state of the callout. |
| LazyRender | `bool` | false | Keeps the content of the callout out of the page until the callout is opened for the first time. Once rendered it stays, so whatever state the content holds survives the callout closing. |
| MaxHeight | `string?` | null | The maximum height of the callout as a CSS value, beyond which its content scrolls. |
| MaxWidth | `string?` | null | The maximum width of the callout as a CSS value, beyond which its content wraps. |
| MaxWindowWidth | `int?` | null | The window width in pixels below which the callout is allowed to hang off the end of the screen rather than being slid back onto it. |
| MinWidth | `string?` | null | The minimum width of the callout as a CSS value, so that a narrow content does not end up in a cramped callout. |
| Modal | `bool` | false | Dims the page behind the callout and holds it still while the callout is open, so that the callout reads as the only thing in play. |
| NoDismissOnEscape | `bool` | false | Keeps the Escape key from dismissing the callout. |
| NoDismissOnOutsideClick | `bool` | false | Keeps the callout open when a click lands outside of it, and when the page is scrolled or resized under it. |
| NoFlip | `bool` | false | Keeps the callout on the Side it was asked for even when there is not enough room for it there, instead of flipping it to the opposite side. |
| NoOverlay | `bool` | false | Leaves the page its own clicks while the callout is open, by not rendering the overlay that otherwise covers it. A Modal callout keeps its overlay. |
| NoShadow | `bool` | false | Removes the box-shadow from the callout. |
| OnDismiss | `EventCallback` | | The callback that is called when the callout is dismissed. |
| OnOpen | `EventCallback` | | The callback that is called when the callout is opened. |
| OnToggle | `EventCallback<bool>` | | The callback that is called when the callout opens or closes. |
| OpenOnHover | `bool` | false | Opens the callout when the pointer enters the anchor and closes it when the pointer leaves both the anchor and the callout. |
| PanelPosition | `BitPanelPosition?` | null | The edge of the screen the responsive panel slides in from, for a ResponsiveMode of Panel. It defaults to End. |
| ResponsiveMode | `BitResponsiveMode?` | null | Configures the responsive mode of the callout for the small screens. |
| Role | `string?` | null | The ARIA role of the callout. It defaults to dialog for a callout that traps the focus, and to nothing for the others. |
| ScrollContainerId | `string?` | null | The id of the element which needs to be scrollable in the content of the callout. |
| ScrollOffset | `int?` | null | The vertical offset of the scroll container to consider in the positioning and height calculation of the callout. |
| SetCalloutWidth | `bool` | false | Widens the callout to at least the width of its anchor, so that a callout with little in it still reads as belonging to what it was opened from. |
| ShowArrow | `bool` | false | Draws an arrow on the edge of the callout that faces the anchor, pointing at it. |
| Side | `BitCalloutSide?` | null | The side of the anchor the callout is placed on when there is room for it there. It wins over Direction, falls back to the opposite side, and then to Direction. |
| Styles | `BitCalloutClassStyles?` | null | Custom CSS styles for different parts of the callout. |
| TrapFocus | `bool` | false | Keeps the keyboard inside the callout while it is open and reports it as a modal dialog to the screen readers. It implies AutoFocus. |
| Width | `string?` | null | The width of the callout as a CSS value. SetCalloutWidth and FixedCalloutWidth take precedence over it. |
| 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. |
| 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. |
| IsEnabled | `bool` | true | Gets or sets a value indicating whether the component is enabled and can respond to user interaction. |
| 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. |
## Public Members
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| Open | `Task` | | Opens the callout programmatically, unless it is disabled. |
| OpenAt | `Task` | | Opens the callout at a point on the screen rather than against an anchor, which is what a context menu needs. It takes the coordinates (double x, double y) or the MouseEventArgs they came from, and moves an already open callout to the new point. |
| Close | `Task` | | Closes the callout programmatically. |
| Toggle | `Task` | | Toggles the callout to open/close it. |
| Reposition | `Task` | | Lays the open callout out again against what it is placed on, without reopening it or replaying its entry animation. It is for what the callout cannot see on its own: a content that has grown or shrunk, or an anchor moved by something other than a resize of it. |
| 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. |
## Enums
### BitDropDirection Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| All | 0 | The direction determined automatically based on the available spaces in all directions. |
| TopAndBottom | 1 | The direction determined automatically based on the available spaces in only top and bottom directions. |
### BitResponsiveMode Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| None | 0 | Disables the responsive mode. |
| Panel | 1 | Enables the panel responsive mode, whose edge comes from the PanelPosition parameter. |
| Top | 2 | Enables the responsive mode as a sheet that comes down from the top of the screen. |
| Bottom | 3 | Enables the responsive mode as a sheet that comes up from the bottom of the screen. |
### BitCalloutSide Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Top | 0 | Above the anchor. |
| Bottom | 1 | Below the anchor. |
| Start | 2 | Beside the anchor, on the side the content starts from - the left in a left-to-right layout. |
| End | 3 | Beside the anchor, on the side the content ends at - the right in a left-to-right layout. |
### BitCalloutAlignment Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Start | 0 | Lined up with the edge the anchor starts at - its left edge in a left-to-right layout for a callout above or below it, and its top edge for a callout beside it. |
| Center | 1 | Centered on the anchor. |
| End | 2 | Lined up with the edge the anchor ends at - its right edge in a left-to-right layout for a callout above or below it, and its bottom edge for a callout beside it. |
### BitPanelPosition Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Start | 0 | The panel slides in from the start edge of the screen. |
| End | 1 | The panel slides in from the end edge of the screen. |
| Top | 2 | The panel slides in from the top edge of the screen. |
| Bottom | 3 | The panel slides in from the bottom edge of the screen. |
### BitColorKind Enum
| Name | Value | Description |
| :--- | :--- | :---------- |
| Primary | 0 | The primary color kind. |
| Secondary | 1 | The secondary color kind. |
| Tertiary | 2 | The tertiary color kind. |
| Transparent | 3 | The transparent color kind. |
### 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. |
## Sub Classes
### BitCalloutClassStyles Properties
| Name | Type | Default Value | Description |
| :--- | :--- | :------------ | :---------- |
| Root | `string?` | null | Custom CSS classes/styles for the root element of the BitCallout. |
| AnchorContainer | `string?` | null | Custom CSS classes/styles for the anchor container element of the BitCallout. |
| Arrow | `string?` | null | Custom CSS classes/styles for the arrow (beak) element of the BitCallout. |
| Opened | `string?` | null | Custom CSS classes/styles for the opened callout state of the BitCallout. |
| Content | `string?` | null | Custom CSS classes/styles for the content of the BitCallout. |
| Header | `string?` | null | Custom CSS classes/styles for the header element of the BitCallout, which is rendered when the Header parameter is set. |
| Body | `string?` | null | Custom CSS classes/styles for the scrolling body element of the BitCallout, which is rendered when the Header or the Footer parameter is set. |
| Footer | `string?` | null | Custom CSS classes/styles for the footer element of the BitCallout, which is rendered when the Footer parameter is set. |
| Overlay | `string?` | null | Custom CSS classes/styles for the overlay of the BitCallout. |
## Examples
\n**Basic**:
```razor
Show callout
NoOverlay
DefaultIsOpen
```
\n**External anchor**:
```razor
AnchorId
```
```csharp
private ElementReference anchorEl;
private BitCallout callout1;
private BitCallout callout2;
```
\n**Context menu**:
```razor
Cut
Copy
Paste
Show callout
Anchor
```
```csharp
private bool isOpen;
```
\n**Open on hover**:
```razor
Hover me
Delayed (500ms)
```
\n**Arrow**:
```razor
With an arrow
Arrow with a border
ArrowSize of 20px
ArrowPadding of 64px
```
\n**Positioning**:
```razor
TopAndBottom
All
Side: Top
Side: End
Side: Top, NoFlip
A wide anchor, centered alignment
A wide anchor, end alignment
Beside, centered
AlignmentOffset of 32px
End alignment, offset of 32px
Gap of 16px
Reposition
@for (int i = 1; i <= repositionRows; i++)
{
Add a row
CollisionPadding of 24px
```
```csharp
private BitCallout callout4 = default!;
private int repositionRows = 2;
private bool repositionAfterRender;
private void AddRepositionRow()
{
repositionRows++;
// The callout is laid out against what is actually in it, so the reposition waits for the render
// that puts the new row there rather than measuring the content the callout still holds.
repositionAfterRender = true;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (repositionAfterRender)
{
repositionAfterRender = false;
await callout4.Reposition();
}
}
```
\n**Sizing**:
```razor
Width
MaxWidth
MaxHeight
A wide anchor with SetCalloutWidth
A wide anchor with FixedCalloutWidth
```
\n**Header & footer**:
```razor
Header & Footer
Wired up by hand
```
\n**Responsive**:
```razor
End panel
Filters
Start panel
Top sheet
Bottom sheet
```
\n**Surface**:
```razor
Background
Border
NoShadow
```
\n**Modal**:
```razor
Modal
Modal with TrapFocus
Submit
```
\n**Keyboard & focus**:
```razor
AutoFocus
Submit
AutoFocus (data-autofocus)
Dismiss
Submit
TrapFocus
Submit
Role & AriaLabel
```
\n**Dismissal**:
```razor
AutoClose (@autoCloseAction)
Rename
Duplicate
Delete
No auto dismiss
```
```csharp
private BitCallout callout3;
private string autoCloseAction = "none";
```
\n**Nesting**:
```razor
Filters
Filters
More options
The panel behind is still open.
One more level
```
\n**Lazy rendering**:
```razor
LazyRender
Pick a date
Rendered up front
Pick a date
```
```csharp
private DateTimeOffset? lazyDate;
private DateTimeOffset? eagerDate;
```
\n**Events**:
```razor
Show callout
Component's Style
Component's Class
Styles
Classes
```
\n**RTL**:
```razor
نمایش کالاوت
همه جهتها
```
This is the callout content.
The page keeps its own clicks while this callout is open.
This callout owns its own open state.
contextCallout.OpenAt(e)" @oncontextmenu:preventDefault>
Right-click anywhere in here
Last action: @contextAction
```
```csharp
private BitCallout contextCallout;
private string contextAction = "none";
```
\n**Binding**:
```razor
This is the callout content.
You can even close it from here!
Done
Cancel
You can even close it from here!
This callout opened on hover.
Both the opening and the closing waited half a second.
This callout points at its anchor.
The beak takes the border of the callout too.
A beak twice the size of the default one.
The beak is held 64px away from the corners of the callout.
@for (int i = 1; i < 23; i++)
{
Callout content @i
}
@for (int i = 1; i < 23; i++)
{
Callout content @i
}
Placed above the anchor whenever there is room above it.
Placed beside the anchor, on the side the content ends at.
@for (int i = 1; i < 13; i++)
{
Callout content @i
}
Centered on the anchor.
Lined up with the end edge.
@for (int i = 1; i < 5; i++)
{
Callout content @i
}
Slid 32px in from the start edge of the anchor.
The same value, running in from the end edge instead.
This callout keeps 16px away from its anchor.
Callout content @i
}
@for (int i = 1; i < 25; i++)
{
Callout content @i
}
A callout of a fixed width.
A long line of text that wraps inside the callout instead of stretching it across the page.
@for (int i = 1; i < 25; i++)
{
Callout content @i
}
Short content, anchor-wide callout.
A long line of text that wraps rather than making the callout wider than its anchor.
@for (int i = 1; i < 69; i++)
{
Callout content @i
}
@for (int i = 1; i < 69; i++)
{
Callout content @i
}
...
...
...
A secondary background.
A primary border.
No elevation, only a border.
The page behind is dimmed.
Everything is up to date.
Neither Escape nor an outside click closes this one.
Close
And so is this one.
This is the callout content.
Toggled: @toggleCount, Opened: @openCount, Dismissed: @dismissCount
```
```csharp
private int openCount;
private int toggleCount;
private int dismissCount;
```
\n**Style & Class**:
```razor
This is the callout content.
This is the callout content.
This is the callout content.
This is the callout content.
این محتوای کالاوت است.
@for (int i = 1; i < 13; i++)
{
محتوای کالاوت @i
}