Skip to content
GitHub11 stars

An accessible popup anchored to a button.

<PopoverRoot>
    <PopoverTrigger class="popover-icon-button" aria-label="Shipping information">
        @InfoIcon

Anatomy

Import the primitives and assemble the parts:

@using Blazix.Primitives

<PopoverRoot>
    <PopoverTrigger />
    <PopoverPortal>
        <PopoverBackdrop />
        <PopoverPositioner>
            <PopoverPopup>
                <PopoverArrow />
                <PopoverViewport>
                    <PopoverTitle />
                    <PopoverDescription />
                    <PopoverClose />
                </PopoverViewport>
            </PopoverPopup>
        </PopoverPositioner>
    </PopoverPortal>
</PopoverRoot>

API Reference

PopoverRoot

Doesn't render its own HTML element.

ParameterTypeDefault
Modal PopupModal PopupModal.False
Open bool false
OpenChanged

Called with the new value when Open changes, for @bind-Open.

EventCallback<bool> -
OnOpenChange EventCallback<OpenChangeEventArgs> -
OnOpenChangeComplete EventCallback<bool> -
Handle PopupHandle? -
ContentTemplate RenderFragment<object?>? -
ChildContent

The part's content.

RenderFragment? -

PopoverTrigger

Renders a <button> element.

ParameterTypeDefault
OpenOnHover bool false
Delay int 300
CloseDelay int 0
Disabled

Whether the component should ignore user interaction.

bool false
Handle PopupHandle? -
Payload object? -
NativeButton bool? -
Render RenderFragment<PopupTriggerRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-popup-open

Present when the corresponding popover is open.

-
data-pressed

Present when the trigger is pressed.

-
data-disabled

Present when the trigger is disabled.

-

PopoverPortal

Doesn't render its own HTML element.

ParameterTypeDefault
KeepMounted bool false
ChildContent

The part's content.

RenderFragment? -

PopoverBackdrop

Renders a <div> element.

ParameterTypeDefault
Render RenderFragment<PopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-open

Present when the popup is open.

-
data-closed

Present when the popup is closed.

-
data-starting-style

Present when the popup begins animating in.

-
data-ending-style

Present when the popup is animating out.

-

PopoverPositioner

Doesn't render its own HTML element.

ParameterTypeDefault
Side Side? -
Align Align? -
SideOffset int? -
AlignOffset int? -
CollisionPadding int? -
ArrowPadding int? -
Sticky bool? -
Anchor string? -
ChildContent

The part's content.

RenderFragment? -
AttributeType
data-open

Present when the popup is open.

-
data-closed

Present when the popup is closed.

-
data-anchor-hidden

Present when the anchor is hidden.

-
data-align

Indicates how the popup is aligned relative to specified side.

'start' | 'center' | 'end'
data-side

Indicates which side the popup is positioned relative to the trigger.

'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'
CSS variableType
--anchor-height

The anchor's height.

number
--anchor-width

The anchor's width.

number
--available-height

The available height between the trigger and the edge of the viewport.

number
--available-width

The available width between the trigger and the edge of the viewport.

number
--positioner-height

The height of the popover's positioner. It is important to set height to this value when using CSS to animate size changes.

number
--positioner-width

The width of the popover's positioner. It is important to set width to this value when using CSS to animate size changes.

number
--transform-origin

The coordinates that this element is anchored to. Used for animations and transitions.

string

PopoverPopup

Renders a <div> element.

ParameterTypeDefault
Side Side? -
Align Align? -
SideOffset int? -
AlignOffset int? -
CollisionPadding int? -
ArrowPadding int 5
Sticky bool false
Anchor string? -
FallbackAxis bool? -
KeepMounted bool false
InitialFocus string? -
FinalFocus string? -
PositionerAttributes IReadOnlyDictionary<string, object>? -
Render RenderFragment<PopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-open

Present when the popup is open.

-
data-closed

Present when the popup is closed.

-
data-align

Indicates how the popup is aligned relative to specified side.

'start' | 'center' | 'end'
data-instant

Present if animations should be instant.

'click' | 'dismiss' | 'focus' | 'trigger-change'
data-side

Indicates which side the popup is positioned relative to the trigger.

'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'
data-starting-style

Present when the popup begins animating in.

-
data-ending-style

Present when the popup is animating out.

-
CSS variableType
--popup-height

The height of the popup.

\`\`
--popup-width

The width of the popup.

\`\`

PopoverArrow

Renders a <div> element.

ParameterTypeDefault
Render RenderFragment<PopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-open

Present when the popup is open.

-
data-closed

Present when the popup is closed.

-
data-uncentered

Present when the popover arrow is uncentered.

-
data-align

Indicates how the popup is aligned relative to specified side.

'start' | 'center' | 'end'
data-side

Indicates which side the popup is positioned relative to the trigger.

'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'

PopoverTitle

Renders a <h2> element.

ParameterTypeDefault
Render RenderFragment<PopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

PopoverDescription

Renders a <p> element.

ParameterTypeDefault
Render RenderFragment<PopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

PopoverClose

Renders a <button> element.

ParameterTypeDefault
Disabled

Whether the component should ignore user interaction.

bool false
NativeButton bool? -
Render RenderFragment<PopupTriggerRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

PopoverViewport

Renders a <div> element.

ParameterTypeDefault
Render RenderFragment<PopupRenderProps>? -
ChildContent

The part's content.

RenderFragment? -

Other attributes are passed to the element it renders.

AttributeType
data-activation-direction

Indicates the direction from which the popup was activated. This can be used to create directional animations based on how the popup was triggered. Contains space-separated values for both horizontal and vertical axes.

`${'left' | 'right' | ''} ${'down' | 'up' | ''}`
data-current

Applied to the direct child of the viewport when no transitions are present or the new content when it's entering.

-
data-instant

Present if animations should be instant.

'click' | 'dismiss' | 'focus' | 'trigger-change'
data-previous

Applied to the direct child of the viewport that contains the exiting content when transitions are present.

-
data-transitioning

Indicates that the viewport is currently transitioning between old and new content.

-
CSS variableType
--popup-height

The height of the parent popup. This variable is placed on the 'previous' container and stores the height of the popup when the previous content was rendered. It can be used to freeze the dimensions of the popup when animating between different content.

\`\`
--popup-width

The width of the parent popup. This variable is placed on the 'previous' container and stores the width of the popup when the previous content was rendered. It can be used to freeze the dimensions of the popup when animating between different content.

\`\`

PopoverHandle