Skip to content

Commit 158e324

Browse files
committed
Tooltip: Fix Chromium mispositioning on inline elements (picocss/pico#678). Add support for explicit line breaks.
1 parent bf3a8dc commit 158e324

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ These µCSS rules exist to fix PicoCSS default behaviors:
5656
- `li ul, li ol { margin-bottom: 0 }` — Fix nested list extra margin (picocss/pico#672) — remove when fixed upstream
5757
- `nav details.dropdown { display: inline-block }` — Fix Firefox full-width nav dropdowns (picocss/pico#701) — remove when fixed upstream
5858
- `:where([role=group], [role=search]) + small` — Fix helper text not styled after input groups (picocss/pico#540, picocss/pico#700) — remove when fixed upstream
59-
- `[data-tooltip]::before { white-space: normal; max-width: 20rem }` — Fix tooltip overflow on long text (picocss/pico#665, picocss/pico#715) — remove when fixed upstream
59+
- `[data-tooltip] { display: inline-block }` — Fix tooltip mispositioned on inline elements in Chromium (picocss/pico#678) — remove when fixed upstream
60+
- `[data-tooltip]::before { white-space: pre-line; max-width: 20rem }` — Fix tooltip overflow on long text, support explicit line breaks (picocss/pico#665, picocss/pico#715) — remove when fixed upstream
6061
- PicoCSS sets `:where(table) { width: 100% }` — all tables are fullwidth by default, no `.table-fullwidth` class needed
6162
- PicoCSS `.outline` button style (3 colors) coexists with µCSS `.btn-outline` (11 colors) — different selectors, no conflict

css/mu.utilities.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ li ol {
2323
color: var(--mu-del-color);
2424
}
2525

26+
/* PicoCSS bugfix: tooltip mispositioned on inline elements in Chromium (picocss/pico#678) — remove when fixed upstream */
27+
[data-tooltip] {
28+
display: inline-block;
29+
}
30+
2631
/* PicoCSS bugfix: tooltips overflow on long text (picocss/pico#665, picocss/pico#715) — remove when fixed upstream */
32+
/* pre-line preserves explicit line breaks (
) while wrapping long text */
2733
[data-tooltip]::before {
28-
white-space: normal;
34+
white-space: pre-line;
2935
max-width: 20rem;
3036
}
3137

documentation/mu.tooltip.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ Tooltips can be placed on form elements to guide the user.
8080

8181
---
8282

83+
## Long text and line breaks
84+
85+
Long tooltip text wraps automatically (max-width: 20rem). You can also force explicit line breaks using `
` in the attribute:
86+
87+
```html
88+
<span data-tooltip="Line 1&#10;Line 2&#10;Line 3">Multiline tooltip</span>
89+
```
90+
91+
---
92+
8393
## Attribute summary
8494

8595
| Attribute | Required | Description |

0 commit comments

Comments
 (0)