Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Basic tooltip

Wrap any control with a short hint, shown on hover or keyboard focus.

A tooltip on a button
Show code
<app-tooltip content="Save your work">
    <app-button>Save</app-button>
</app-tooltip>

Placement

Choose the side the tip opens on; it flips to stay in view if the edge is near.

Placement options
Show code
<app-tooltip content="Top" placement="Top"><app-button tone="Neutral" variant="Outline" size="WideSize.Sm">Top</app-button></app-tooltip>
<app-tooltip content="Bottom" placement="Bottom"><app-button tone="Neutral" variant="Outline" size="WideSize.Sm">Bottom</app-button></app-tooltip>
<app-tooltip content="Start" placement="Start"><app-button tone="Neutral" variant="Outline" size="WideSize.Sm">Start</app-button></app-tooltip>
<app-tooltip content="End" placement="End"><app-button tone="Neutral" variant="Outline" size="WideSize.Sm">End</app-button></app-tooltip>

Content

The content is plain text. React's <AppTooltip> accepts any rich ReactNode for its content prop: bold text, multiple lines, inline elements. Razor's <app-tooltip> renders once on the server, so content is a plain string only.

Shortcut

Show the key that runs an action in its tip, for an action people repeat many times a day.

Approve with A
Show code
<app-tooltip content="Approve the request" shortcut="a">
    <app-button>Approve</app-button>
</app-tooltip>
<app-tooltip content="Archive" shortcut="e" variant="AppTooltipVariant.Inverse">
    <app-button tone="Neutral" variant="Outline">Archive</app-button>
</app-tooltip>

On icon buttons

Use a tip on an icon-only control, where the icon alone may not say what it does.

Icon buttons with tips
Show code
<app-tooltip content="Download report">
    <app-action-icon icon="download" label="Download"></app-action-icon>
</app-tooltip>
<app-tooltip content="Edit details">
    <app-action-icon icon="pencil" label="Edit"></app-action-icon>
</app-tooltip>
<app-tooltip content="Delete item">
    <app-action-icon icon="trash-2" label="Delete" tone="AppActionIconTone.Danger"></app-action-icon>
</app-tooltip>

Tones and sizes

Pick a preset tone or size for a tip; the defaults suit most controls.

Tone presets
tone=neutral
variant=inverse
tone=primary
tone=success
tone=warning
tone=danger
Show code
<app-tooltip content="Tone: neutral" tone="Neutral"><app-button variant="Soft" tone="Neutral" size="WideSize.Sm">Neutral</app-button></app-tooltip>
<app-tooltip content="Variant: inverse" variant="AppTooltipVariant.Inverse"><app-button variant="Outline" size="WideSize.Sm">Inverse</app-button></app-tooltip>
<app-tooltip content="Tone: primary" tone="Primary"><app-button size="WideSize.Sm">Primary</app-button></app-tooltip>
<app-tooltip content="Tone: success" tone="Success"><app-button tone="Neutral" size="WideSize.Sm">Success</app-button></app-tooltip>
<app-tooltip content="Tone: warning" tone="Warning"><app-button tone="Warning" size="WideSize.Sm">Warning</app-button></app-tooltip>
<app-tooltip content="Tone: danger" tone="Danger"><app-button tone="Danger" size="WideSize.Sm">Danger</app-button></app-tooltip>
Fully custom colour via CSS vars
Show code
/* in your stylesheet */
.tip-brand { --wui-tooltip-bg: var(--color-primary); --wui-tooltip-color: var(--color-on-primary); }

<app-tooltip content="On brand" class="tip-brand">
    <app-button variant="Outline">Custom</app-button>
</app-tooltip>
Size presets
size=sm
size=md (default)
size=lg
Show code
<app-tooltip content="Small tip" size="Sm"><app-button variant="Outline" size="WideSize.Sm">Small</app-button></app-tooltip>
<app-tooltip content="Medium tip" size="Md"><app-button variant="Outline">Medium</app-button></app-tooltip>
<app-tooltip content="Large tip" size="Lg"><app-button variant="Outline" size="WideSize.Lg">Large</app-button></app-tooltip>
Fully custom size via CSS vars
Show code
/* in your stylesheet */
.tip-xl {
    --wui-tooltip-font-size: 1rem;
    --wui-tooltip-padding-y: 12px;
    --wui-tooltip-padding-x: 16px;
    --wui-tooltip-max-width: 340px;
}

<app-tooltip content="A roomy custom tip" class="tip-xl">
    <app-button variant="Outline">Custom size</app-button>
</app-tooltip>

Every option

Every value of every prop, one cell each.

content: short, long and rich

content="Short tip"
content="A longer explanatory tooltip that wraps onto more than one line"
content={<><strong>Bold</strong> + text</>} (React only)

children: the trigger element

trigger: app-button
trigger: app-action-icon
trigger: plain input
trigger: aria-disabled button, still focusable

placement: all five

placement="auto"
placement="top" (default)
placement="bottom"
placement="start"
placement="end"

tone: all five

tone="neutral" (default)
tone="primary"
tone="success"
tone="warning"
tone="danger"

variant: inverse

variant="inverse"

size: all three

size="sm"
size="md" (default)
size="lg"

shortcut: the key chip

shortcut="a"

open: shows the tip

open="false" (default)
open="true"

className: extra class

class="sc-tip-brand" (sets the --wui-tooltip-* vars)

Guidance

What to do, and what to avoid.

Use it when

  • Quick, context-sensitive hints on icon buttons, abbreviations, shortcuts.
  • Brief content: a sentence or two, never a help article.
  • Alongside clear labels or icons, not instead of them.

Reach for something else when

  • Essential information: not everyone hovers, so put it in visible copy.
  • Help text that exists only in the tooltip; repeat it in the form or docs.
  • Tooltips on every element: clutter trains people to ignore them.

Reference

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

auto top bottom start end
neutral primary success warning danger
none inverse
sm md lg
React, generated from the controls
<AppTooltip content="Tooltip text" placement="auto" variant="inverse" size="sm">
  <AppButton variant="outline">Hover or focus me</AppButton>
</AppTooltip>
Razor, the same props
<app-tooltip content="Tooltip text" placement="Auto" variant="AppTooltipVariant.Inverse" size="Sm">
    <app-button variant="Outline">Hover or focus me</app-button>
</app-tooltip>

9 props. The 5 most used come first.

Used on most screens 5 props

PropTypeDefaultDescription
contentdefault - string - The tooltip text (required). Same as React content.
placementdefault top auto | top | bottom | start | end top Where the tooltip appears. A named side is preferred but flips if needed to stay in view; auto lets Popper pick the side with the most room outright. Either way the tooltip never clips off-screen.
tonedefault neutral neutral | primary | success | warning | danger neutral Preset colour of the tooltip. neutral is the light surface look; the others are solid tints. For a fully custom colour, pass a class whose rule sets the --wui-tooltip-bg, --wui-tooltip-color, --wui-tooltip-border and --wui-tooltip-radius CSS vars.
variantdefault - inverse - inverse draws the tooltip on a dark surface, for a tip inside a light page.
sizedefault md sm | md | lg md Preset size (font size, padding and max width). For a fully custom size, pass a class that sets the --wui-tooltip-font-size, --wui-tooltip-padding-y, --wui-tooltip-padding-x and --wui-tooltip-max-width CSS vars.

Less common 4 props

PropTypeDefaultDescription
shortcutdefault - string - The key that runs the action ("A", "E", "/"), drawn as a key chip after the text ("Approve A"). One character is written in upper case.
opendefault false bool false Shows the panel open, for a design preview or a controlled caller.
classdefault - string - Forwarded onto the tooltip; use it to set custom --wui-tooltip-* CSS vars.
(content)default - - - Child content: the trigger element (any markup).

Screen reader

3 notes
  • The tooltip opens on hover and on keyboard focus of the trigger, so keyboard users get the same hint.
  • The tooltip carries a generated id, and the trigger points at it with aria-describedby while it is open.
  • Placement flips to stay inside the viewport, but essential information still belongs in visible copy.