# Showing Kendo UI for Angular Tooltip on Focus

## Environment

<table>
    <tbody>
        <tr>
            <td>Product</td>
            <td>Progress® Kendo UI® for Angular Tooltip</td>
        </tr>
    </tbody>
</table>

## Description

I want to make the [Kendo UI for Angular Tooltip](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/tooltip) keyboard accessible by displaying it when an element gains focus. How can I achieve this functionality for the Tooltip component?

This Knowledge Base article also answers the following questions:

* How to show the Kendo UI for Angular Tooltip on focus?
* How to make the Tooltip keyboard accessible in Kendo UI for Angular?
* How to use the `focus` and `blur` events of an HTML element in combination with the Kendo UI for Angular Tooltip?
* How to show tooltips on Tab key navigation?

## Solution

To display the Kendo UI for Angular Tooltip when focusing a certain element, use Angular's event bindings along with the [`show`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/tooltipdirective#show) and [`hide`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/tooltipdirective#hide) methods that the [`TooltipDirective`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/tooltipdirective) provides.

You can find below more detailed steps for achieving the desired behavior:

1. Use the `focus` event of the HTML element, on which the `TooltipDirective` is applied, to show the Tooltip when the element gains focus.
2. Use the `blur` event of the HTML element to hide the Tooltip when the element loses focus.
3. Set the [`showOn`](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/tooltipdirective#showon) property of the `TooltipDirective` to `"none"` in order to disable the built-in display of the Tooltip on hover and allow [programmatic control](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/tooltip/opening) of the Tooltip's visibility.

```html
<ng-template #template let-anchor>My Tooltip on focus</ng-template>

<div
  kendoTooltip
  #tooltip="kendoTooltip"
  [tooltipTemplate]="template"
  (focus)="showTooltip(myElement)"
  (blur)="hideTooltip()"
  showOn="none"
  tabindex="0"
>
  <div #myElement>Focus me to see the tooltip</div>
</div>
```

```ts
@ViewChild(TooltipDirective) tooltipDir: TooltipDirective;

public showTooltip(element: HTMLElement): void {
  this.tooltipDir.show(element);
}

public hideTooltip(): void {
  this.tooltipDir.hide();
}
```

The following example demonstrates the suggested approach in action.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/show-tooltip-on-focus/source.txt)

The following example shows how to create a reusable directive that can be applied to any focusable element to show the Tooltip on focus.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/tooltip-keyboard-focus/source.txt)

## See Also

* [Kendo UI for Angular Tooltip Programmatic Control](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/tooltip/opening)
* [Kendo UI for Angular Tooltip Overview](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/tooltip)
* [API Reference of the TooltipDirective](https://www.telerik.com/kendo-angular-ui-develop/components/tooltips/api/tooltipdirective)
