# Tooltip

This component renders the tooltip *content* only. The hover/focus trigger is `{@attach tooltip(text)}` from `q-design-ui/attachments/tooltip`; the component owns the look, the attachment owns the behavior. Never use the native `title` attribute.

## Strings

A string is the common case: one short hint. It is never parsed as HTML, so a name with markup in it is safe.

## Snippets

A snippet carries inline markup where the hint needs emphasis.

## A title and lines

`tooltip({ title, lines })`: the title in the label face, each line under it smaller and quieter, all text. The trigger's description reads them together, joined by ". ".

## Length and width

Long content clamps to 3 lines by default, so no tooltip dominates the viewport; `maxLines` changes the clamp. `maxWidth` narrows the bubble for a tight spot.

## Components

A component and its props, for content richer than text: metadata, a small chart, a status panel.

## Examples

```svelte
<script lang="ts">
  import Tooltip from '@qualia-studios/design-ui/components/Tooltip.svelte';
</script>

{#snippet emphasis()}
  Supports <strong>inline markup</strong> for emphasis or <em>links</em>.
{/snippet}
```

### Example 1: A short hint

```svelte
<Tooltip content="A short tooltip explanation." />
```

### Example 2: Markup in a string, drawn as written

```svelte
<Tooltip content={'A name like <b>x</b> & co is drawn as written.'} />
```

### Example 3: A snippet with inline markup

```svelte
<Tooltip content={emphasis} />
```

### Example 4: A title over two lines

```svelte
<Tooltip
  content={{
    title: '3 notes',
    lines: ['Agnes · 10:42', 'The gripper slips on the second grasp'],
  }}
/>
```

### Example 5: Long content, clamped at three lines

```svelte
<Tooltip
  content="A much longer tooltip that demonstrates the line-clamp behavior. By default it clamps to 3 lines but you can pass maxLines to change it. The default clamp prevents any single tooltip from dominating the viewport."
/>
```

### Example 6: Long content, clamped at one line

```svelte
<Tooltip
  maxLines={1}
  content="A much longer tooltip that demonstrates the line-clamp behavior, but with maxLines set to 1."
/>
```

### Example 7: A narrower bubble

```svelte
<Tooltip maxWidth="200px" content="Constrained to 200px wide." />
```

### Example 8: A component with props

```svelte
<Tooltip
  content={{
    component: RichExample as Component<any>,
    props: { name: 'q-design-ui', version: '0.1.0' },
  }}
/>
```

---

From the Qualia design guide: https://q-core-3b2732.gitlab.io/components/tooltip. Every page as markdown: https://q-core-3b2732.gitlab.io/llms.txt
