Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Anchored panel

Use a panel beside a trigger for richer content than a menu, such as notifications or a short form.

A notifications panel
Show code
<app-popover title="Notifications">
    <app-popover-trigger><app-button variant="Ghost" left-icon="bell">Notifications</app-button></app-popover-trigger>
    <app-popover-body>
        <div class="d-flex flex-column gap-2">
            <div>Priya approved <strong>Site survey #48</strong>.</div>
            <div>New comment on “Risk assessment”.</div>
        </div>
    </app-popover-body>
</app-popover>

Title or body only

Add a title for a labelled panel; leave it out when the body explains itself.

A filters panel, body only
Show code
<app-popover>
    <app-popover-trigger><app-action-icon icon="filter" label="Filters"></app-action-icon></app-popover-trigger>
    <app-popover-body>
        <div class="d-flex flex-column gap-2">
            <label class="d-flex align-items-center gap-2"><input type="checkbox" checked /> Open</label>
            <label class="d-flex align-items-center gap-2"><input type="checkbox" /> Archived</label>
        </div>
    </app-popover-body>
</app-popover>

Placement

Choose the side the panel opens on, or let auto flip it to whichever side has room.

Every placement
Show code
<app-popover placement="Top" title="Top">…</app-popover>
<app-popover placement="Bottom" title="Bottom">…</app-popover>
<app-popover placement="Start" title="Start">…</app-popover>
<app-popover placement="End" title="End">…</app-popover>
<app-popover placement="Auto" title="Auto">…</app-popover>

What opens it

Use hover with focus for a quick preview; keep click for anything a person must open on purpose.

Click, hover and focus
Show code
<app-popover trigger-type="click" title="Click">…</app-popover>
<app-popover trigger-type="hover focus" title="Hover">…</app-popover>
<app-popover trigger-type="focus" title="Focus">…</app-popover>

Every option

Every value of every prop, one cell each.

trigger: one element

<app-popover-trigger>: any markup, here an icon

children: the panel body

<app-popover-body>: any content, and long text grows the panel

title: with and without

title="Notifications": header rendered
(no title): body-only panel

placement: all five

placement="top"
placement="bottom" (default)
placement="start"
placement="end"
placement="auto": flips to stay in view

triggerType: every value

trigger-type="click" (default)
trigger-type="focus"
trigger-type="hover focus": hover or keyboard focus
trigger-type="hover" (pair with focus for keyboard and touch)

onOpenChange: reports open and close

onOpenChange={fn} (React only): here, listen for shown.bs.popover
onClick (Razor: a click on the trigger)

aria-expanded is not a prop: the popover sets it on the trigger to match the open state, so it has no cell.

open: held open or closed

open={true} and open={false} (React only): here, trigger-type alone opens it

role: none or dialog

(no role) (default)
role="dialog": named by the title, Escape closes it

labelledBy: names a dialog

labelled-by="pop-demo-name": names the dialog, and wins over the title

autoFocus: off and on

(no auto-focus) (default): focus stays on the trigger
auto-focus="true": moves focus into the panel on open

className: extra classes

class="text-primary": the class lands on the host span

openDelay: hover open delay

open-delay="80" (default): a hover waits 80 ms
open-delay="0": a hover opens at once

closeDelay: hover close delay

close-delay="220" (default): a hover waits 220 ms to close
close-delay="0": a hover closes at once

Guidance

What to do, and what to avoid.

Use it when

  • A trigger needs a floating panel of content richer than a flat action list: a notifications feed, a filters form, a mini preview.
  • The content is contextual to the trigger and doesn’t need a backdrop or to interrupt the page.
  • You want the panel positioned and flipped to stay in view automatically.

Reach for something else when

  • The content is a flat list of actions. → AppDropdown
  • The task needs full attention, such as a form, a multi-step flow or a destructive confirmation. → AppModal
  • You are explaining a single term next to a label. → AppInfoTip

Keep the panel short

Do

A short, scannable panel: a few lines the user can read without scrolling.

Avoid

A multi-field form crammed into a popover has nowhere to show validation and no backdrop to hold focus. Use AppModal instead.

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

top bottom start end auto
click hover focus hover focus
(none) dialog
React, generated from the controls
<AppPopover title="Notifications" placement="top"
  trigger={<AppButton variant="soft" size="sm">Open</AppButton>}
  onOpenChange={fn}
>
  Panel body content.
</AppPopover>
Razor, the same props
<app-popover title="Notifications" placement="Top">
    <app-popover-trigger><app-button variant="Soft" size="WideSize.Sm">Open</app-button></app-popover-trigger>
    <app-popover-body>Panel body content.</app-popover-body>
</app-popover>

11 props. The 3 most used come first.

Used on most screens 3 props

PropTypeDefaultDescription
titledefault - string - An optional panel title, plain text so it never breaks the page's heading order.
placementdefault bottom top | bottom | start | end | auto bottom Where the panel opens. auto flips to stay in view.
roledefault - dialog - dialog names the panel after the title or labelled-by, marks it not modal, and lets Escape close it.

Less common 8 props

PropTypeDefaultDescription
app-popover-triggerdefault - markup - Child slot: the anchor element the panel opens from.
app-popover-bodydefault - markup - Child slot: the panel body.
trigger-typedefault click click | hover | focus, or a space-separated combination (e.g. hover focus) click What opens the panel. Razor takes the same combinations as a space-separated string, such as hover focus.
labelled-bydefault - string - The id of the element that names a dialog panel. It wins over the title.
auto-focusdefault false bool false Moves focus into the panel on open and back to the trigger on close.
open-delaydefault 80 int 80 Milliseconds a hover popover waits before it opens.
close-delaydefault 220 int 220 Milliseconds a hover popover waits before it closes after the pointer leaves the trigger and the panel.
classdefault - string - Extra classes on the panel host span.

Screen reader

3 notes
  • With role dialog the panel is named by the title, or by the element labelledBy points to (which wins), is marked not modal, and Escape closes it.
  • With autoFocus focus moves into the panel on open and back to the trigger on close.
  • The trigger is the caller's own element with aria-expanded added for a click trigger, so it needs its own accessible name.

Do and avoid

1 pairs

Keep the panel short

Do

A short, scannable panel: a few lines the user can read without scrolling.

Avoid

A multi-field form crammed into a popover has nowhere to show validation and no backdrop to hold focus. Use AppModal instead.