Tooltip
Show a brief explanation on hover or focus.
Examples
Show a brief explanation on hover or focus
React code
import { Tooltip, Button, TooltipContent } from "@accelerate/react/components";
export function Example() {
return (
<>
<Tooltip>
<Button aria-describedby="archive-tip" variant="outline">Archive</Button>
<TooltipContent id="archive-tip">Moves the item out of the active queue.</TooltipContent>
</Tooltip>
</>
);
}Angular code
import { Component } from "@angular/core";
import {
AccTooltip,
AccButton,
AccTooltipContent,
} from "@accelerate/angular/components";
@Component({
selector: "app-example",
imports: [
AccTooltip,
AccButton,
AccTooltipContent,
],
template: `
<span accTooltip>
<button accButton aria-describedby="archive-tip" variant="outline">Archive</button>
<span accTooltipContent id="archive-tip">Moves the item out of the active queue.</span>
</span>
`,
})
export class Example {}Installation
Source preview. The expanded component catalog is ahead of the public npm releases. To run these examples in your own application, use packages built from the SDK source used for the previews or a release that includes the APIs below.
- React
@accelerate/ui@0.4.0and@accelerate/react@0.4.0- Angular
@accelerate/ui@0.4.0and@accelerate/angular@0.2.0
Load @accelerate/ui/theme.css and put acc-theme on the app or the region using Accelerator components. See the framework setup guide for the theme and adapter conventions.
Usage
Link a focusable trigger to TooltipContent with aria-describedby. Focus and hover reveal it. Escape dismisses it.
Import the React component Tooltip from @accelerate/react/components. For Angular, add AccTooltip to the standalone component’s imports and use <span accTooltip>.
Examples use these React parts: Tooltip, Button, TooltipContent. The Angular examples show the corresponding directives and template hosts.
API reference
- aria-describedby
- Associates the trigger with TooltipContent.
- Escape
- Dismisses the tooltip while leaving focus on the trigger.