oakoss/ui
Components

Contextual Help

An icon button beside a label that opens an explanation, for help a tooltip can't hold or touch can't reach.

SourceReact Aria
Workspace ID

Installation

npx shadcn@latest add @oakoss/contextual-help

This also installs Popover, whose parts make up the content, and Button.

Usage

import { ContextualHelp } from '#/components/ui/overlays/contextual-help';
import {
  PopoverBody,
  PopoverHeader,
  PopoverTitle,
} from '#/components/ui/overlays/popover';

<ContextualHelp>
  <PopoverHeader>
    <PopoverTitle>Title</PopoverTitle>
  </PopoverHeader>
  <PopoverBody>Explanation</PopoverBody>
</ContextualHelp>;

Examples

Info

variant="info" shows an info icon, named "Information", for background rather than instructions.

Storage used

Beside a field label

Put ContextualHelp next to the FieldLabel in a row, not inside it: inside the label, its name joins the field's, so the input is read as "Workspace ID Help".

Accessibility

The trigger is a Button named by helpLabel ("Help") or infoLabel ("Information"), so it works with a keyboard, a screen reader and touch, where a Tooltip doesn't open. Enter or Space opens a Popover, which takes its name from a PopoverTitle in the content, or the button's label without one. Focus moves into it, Tab stays inside, and Escape closes it and returns focus to the button. A disabled field keeps its help reachable: the button never takes a surrounding field's props, so it stays enabled inside a disabled NumberField or Select and opens its own popover.

In Arabic, Persian and Urdu the help icon mirrors, as those scripts write the question mark (؟); Hebrew, which uses "?", and the info icon don't.

Follows the WAI-ARIA dialog pattern.

API

ContextualHelp

Renders our Popover with a ghost icon Button as its trigger. className applies to the button.

Props

Prop

Type

placement defaults to bottom start, so the popover lines up with the button's start edge.

Data attributes

AttributePresent when
data-slotAlways, on the button: contextual-help-trigger