# Tooltip

Source: https://ecosphere.dev/docs/feedback/tooltip (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

A short label beside a control with no visible text: the [data-tip] bubble as a component, wired to its trigger with aria-describedby.

`import { EcoTooltip } from "vue-ecosphere"`

## Tooltip

Hover for 400ms or tab to the button. The icon button keeps its own aria-label: the tooltip describes, it never names. Escape hides it.

Vue (vue-ecosphere):

```vue
<EcoTooltip text="Copy link">
  <EcoIconButton label="Copy link" icon="link" />
</EcoTooltip>
```

React (react-ecosphere):

```tsx
<EcoTooltip text="Copy link">
  <EcoIconButton label="Copy link" icon="link" />
</EcoTooltip>
```

## Placement

The bubble sits against the trigger, not in a layer above the page: choose the side that clears the edge of a scrolling or clipped container.

Vue (vue-ecosphere):

```vue
<EcoTooltip text="Above" placement="top"><EcoIconButton label="Top" icon="arrow-up-line" outlined /></EcoTooltip>
<EcoTooltip text="Below" placement="bottom"><EcoIconButton label="Bottom" icon="arrow-down-line" outlined /></EcoTooltip>
<EcoTooltip text="Before" placement="start"><EcoIconButton label="Start" icon="arrow-left-line" outlined /></EcoTooltip>
<EcoTooltip text="After" placement="end"><EcoIconButton label="End" icon="arrow-right-line" outlined /></EcoTooltip>
```

React (react-ecosphere):

```tsx
<EcoTooltip text="Above" placement="top"><EcoIconButton label="Top" icon="arrow-up-line" outlined /></EcoTooltip>
<EcoTooltip text="Below" placement="bottom"><EcoIconButton label="Bottom" icon="arrow-down-line" outlined /></EcoTooltip>
<EcoTooltip text="Before" placement="start"><EcoIconButton label="Start" icon="arrow-left-line" outlined /></EcoTooltip>
<EcoTooltip text="After" placement="end"><EcoIconButton label="End" icon="arrow-right-line" outlined /></EcoTooltip>
```

## Rich content

The content slot takes a little markup, such as the shortcut. Do not set the icon button's own tip as well.

Vue (vue-ecosphere):

```vue
<EcoTooltip placement="bottom">
  <EcoIconButton label="Save draft" icon="save-3-line" />
  <template #content>Save draft <span class="note">⌘S</span></template>
</EcoTooltip>
```

React (react-ecosphere):

```tsx
<EcoTooltip placement="bottom" content={<>Save draft <span className="note">⌘S</span></>}>
  <EcoIconButton label="Save draft" icon="save-3-line" />
</EcoTooltip>
```

## EcoTooltip

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `text` | `string` | — | A few words, no full stop. The #content slot overrides it. |
| `placement` | `"top" \| "bottom" \| "start" \| "end"` | "top" | Side of the trigger; start and end follow the writing direction. |
| `disabled` | `boolean` | false | No bubble, and the trigger's aria-describedby is removed. |
| `#default` | `slot` | — | One focusable trigger. Its first element gets aria-describedby pointing at the bubble. |
| `#content` | `slot` | — | Richer bubble text (a shortcut, a short emphasis). Nothing to click. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `text` | `string` | — | A few words, no full stop. content overrides it. |
| `placement` | `"top" \| "bottom" \| "start" \| "end"` | "top" | Side of the trigger; start and end follow the writing direction. |
| `disabled` | `boolean` | false | No bubble, and the trigger's aria-describedby is removed. |
| `children` | `ReactNode` | — | One focusable trigger. Its first element gets aria-describedby pointing at the bubble. |
| `content` | `ReactNode` | — | Richer bubble text (a shortcut, a short emphasis). Nothing to click. |
