Re: [csswg-drafts] [css-ui] Standardize tooltip styling and expose as `::tooltip` (#8930)

The CSS Working Group just discussed ``[css-ui] Standardize tooltip styling and expose as `::tooltip` ``, and agreed to the following:

* `RESOLVED: Standardize a ::tooltip pseudo, with a few properties, to style tooltips`

<details><summary>The full IRC log of that discussion</summary>
&lt;fremy> lea: proposal as of a few days ago<br>
&lt;fremy> lea: tooltip styling has been brought up multiple times<br>
&lt;fremy> lea: first was tantek, but there were many other ones<br>
&lt;fantasai> s/times/times by multiple people since 2000/<br>
&lt;fremy> lea: every single time, there was little pushback<br>
&lt;fremy> lea: yet it never went anywhere<br>
&lt;fremy> lea: many websites have custom code to style tooltips<br>
&lt;fremy> lea: and most of these stylings are not very fancy<br>
&lt;fremy> lea: mostly color, background, font-style, customizing the delays...<br>
&lt;fremy> lea: because browsers sometimes wait too much<br>
&lt;fremy> lea: but all of this requires chaning the markup, because the element must wrap the location<br>
&lt;fremy> lea: so this is pretty heavy-weight, and it's easy to forget some accessiblity requirements<br>
&lt;fremy> lea: so, I really think we should do something about it<br>
&lt;castastrophe_> +1 lea I argued so hard against our library building a tooltip web component at work<br>
&lt;fremy> lea: and the most common proposal is a pseudo-element acceting a few properties<br>
&lt;masonf> q?<br>
&lt;masonf> q+<br>
&lt;fremy> lea: since the tooltips can escape the window bounds, it could make huge tooltips and confuse the users if everything is customizable<br>
&lt;fremy> lea: but some properties sound fine<br>
&lt;una> q+<br>
&lt;fremy> lea: later on, we can add positioning, maybe using anchor positioning, but magic is fine for MVP<br>
&lt;gregwhitworth> q+<br>
&lt;fremy> lea: content itself can probably be magic too, because SVG and HTML do this differently<br>
&lt;fremy> lea: keyword vs totally magic, not that important<br>
&lt;fremy> lea: we can narrow this down later<br>
&lt;fremy> lea: later on, we can add html elements, attributes, focusable, etc...<br>
&lt;fremy> lea: but I see consensus on the basics<br>
&lt;fremy> lea: so, are there implementors that are concerned about this?<br>
&lt;gregwhitworth> note, I'm not an implementer anymore :P<br>
&lt;fremy> lea: (also, maybe javascript-created tooltips?)<br>
&lt;castastrophe_> A reference for anyone interested in Adobe's tooltip web component: https://opensource.adobe.com/spectrum-web-components/components/tooltip/#example<br>
&lt;fremy> lea: maybe in that case, bound to the frame<br>
&lt;castastrophe_> And an example from Shoelace: https://shoelace.style/components/tooltip<br>
&lt;masonf> q?<br>
&lt;fremy> lea: so, what are the constraints holding us back here?<br>
&lt;gregwhitworth> ack gregwhitworth<br>
&lt;emilio> q+<br>
&lt;astearns> ack masonf<br>
&lt;fremy> masonf: thank you for bringing this up<br>
&lt;masonf> Shameless plug for popover=hint and hover triggering: https://open-ui.org/components/popover-hint.research.explainer/<br>
&lt;fremy> masonf: I pasted our shim in the chat, a more complex version of this<br>
&lt;ntim> q+<br>
&lt;fremy> masonf: but for most use cases I have seen, a few styling would go a long way<br>
&lt;fremy> masonf: I would love it to have the tooltip in the window bounds, so that styled tooltips are consistent depending on how much they are styled<br>
&lt;fantasai> s/complex version of this/complex version of this using popover/<br>
&lt;fremy> masonf: I would prefer some things to remain magic, like delays, but ok<br>
&lt;fremy> masonf: html uses the title element, but also some aria attributes<br>
&lt;astearns> ack masonf<br>
&lt;astearns> ack una<br>
&lt;fremy> una: thank you for opening this issue<br>
&lt;myles> q+<br>
&lt;lea> q?<br>
&lt;fremy> una: the first thought that comes to mind, can this also style "form error messages"<br>
&lt;masonf> we should support the title attribute for HTML, or the &lt;title> element with svg.<br>
&lt;fremy> una: does that also apply to "alt text" over images?<br>
&lt;fremy> una: maybe, this can be a "style bag" rather than a pseudo-element<br>
&lt;lea> q+<br>
&lt;emilio> q- later<br>
&lt;fremy> una: but, if you have a popover, that gives you multiple elements, and more flexibility<br>
&lt;fremy> una: so, the limitations of this proposal, are they acceptable enough, is my first question<br>
&lt;fremy> una: my second question, is that, how does this related to other features like alt text<br>
&lt;astearns> ack ntim<br>
&lt;SebastianZ> q+<br>
&lt;fremy> ntim: outside of the window bounds, we would want to filter down to a list of properties<br>
&lt;masonf> q+<br>
&lt;fremy> ntim: also, probably some constraints like size or box-shadow<br>
&lt;astearns> ack myles<br>
&lt;fremy> myles: further than that, tooltips ship with the OS, and the platform usually don't allow much styling<br>
&lt;fremy> myles: so, one limit, I would start with what the platform allows<br>
&lt;gregwhitworth> q+<br>
&lt;fremy> myles: also, tooltips outside the window, requires nsWindow etc...<br>
&lt;fremy> myles: this is costly if we want to do that<br>
&lt;fremy> myles: but I understand that from the issue, the benefits are also quite high<br>
&lt;fremy> myles: so, this is not "easy" at least<br>
&lt;fremy> astearns: the rest of the proposal doesn't get to that bar?<br>
&lt;astearns> ack lea<br>
&lt;fremy> myles: yes<br>
&lt;fremy> lea: I think errors for form controls are a different pseudo, because they have different constraints<br>
&lt;astearns> s/the rest/the hard part is displaying outside the window. The rest<br>
&lt;fremy> lea: there are commonalities, but also major differences<br>
&lt;fremy> lea: I'm not seeing the alt text connection, which I think is more of a ::part() I think<br>
&lt;una> q?<br>
&lt;fremy> lea: to reply to ntim, I would definitely favor an allow list<br>
&lt;fremy> lea: but, just an allow-list might not be the whole story<br>
&lt;fremy> lea: I think many authors want padding, rounded borders, etc...<br>
&lt;fremy> lea: to reply to myles, I think this would generate non-native tooltips<br>
&lt;myles> q+ to reply to that<br>
&lt;fremy> lea: because what authors do today is this<br>
&lt;gregwhitworth> ack gregwhitworth<br>
&lt;fremy> una: what do you think of popover=hint?<br>
&lt;fremy> lea: it can probably solve some, but it requires a lot of code, and doesn't play natively with title attribute etc<br>
&lt;fantasai> s/what do you think of popover=hint/do you think popover=hint solving these problems?<br>
&lt;fantasai> s/solving/solves/<br>
&lt;gregwhitworth> I agree with Lea on this<br>
&lt;fremy> lea: more complex use cases would like it<br>
&lt;astearns> ack myles<br>
&lt;Zakim> myles, you wanted to reply to that<br>
&lt;lea> q?<br>
&lt;fremy> myles: if this is not native tooltip, for us this is not a tooltip<br>
&lt;fremy> myles: I would not want to call this a tooltip at this point<br>
&lt;gregwhitworth> q+<br>
&lt;astearns> ack emilio<br>
&lt;fremy> emilio: indeed, we need to answer whether the content area is enough (even for iframes)<br>
&lt;fremy> emilio: if not, non-native tooltips are not ok<br>
&lt;lea> q+<br>
&lt;fremy> emilio: but we already discussed this for &lt;selectmenu> elements<br>
&lt;TabAtkins> These are conditions that people already live with when they're using the custom JS-driven versions.<br>
&lt;fremy> emilio: so, if we are, this seems workable<br>
&lt;fremy> emilio: if we don't think this is sufficient, I would not think that this is doable (in a reasonable amount of effort)<br>
&lt;gregwhitworth> note, only when ::tooltip is present<br>
&lt;fremy> emilio: so, would browsers engines be fine with that?<br>
&lt;fremy> emilio: and I have the impression that myles isn't confortable with that, maybe?<br>
&lt;fremy> emilio: personally, I guess I'm fine, but needs some thoughts<br>
&lt;lea> q?<br>
&lt;fremy> astearns: TabAtkins replied on IRC that people today have those limitations, so those are probably ok with them<br>
&lt;gregwhitworth> not if you don't use ::tooltip<br>
&lt;fremy> emilio: but those aren't native, right?<br>
&lt;fremy> TabAtkins: yes, they override<br>
&lt;astearns> ack SebastianZ<br>
&lt;fremy> SebastianZ: I wanted to say more about the security issue<br>
&lt;fremy> SebastianZ: the native tooltips should still be able to actual document<br>
&lt;fremy> SebastianZ: right now, UAs can clip the text etc..., UAs can create new rules based on size etc...<br>
&lt;fremy> SebastianZ: do we have concensus that this is something that should be worked on, at least?<br>
&lt;masonf> I'll rejoin<br>
&lt;astearns> ack masonf<br>
&lt;fremy> masonf: &lt;confusing echo><br>
&lt;astearns> ack gregwhitworth<br>
&lt;fremy> gregwhitworth: personally, I never envisioned the non-native tooltips to escape the bounds<br>
&lt;fremy> gregwhitworth: and I think, as an author, that is reasonable<br>
&lt;fremy> gregwhitworth: but even then, we can start with simple properties anyway<br>
&lt;fremy> gregwhitworth: una pointed out alt text, and some sites use them as a tooltip in some cases<br>
&lt;fremy> gregwhitworth: also, agree with myles, maybe this shouldnt be called a tooltip<br>
&lt;fremy> gregwhitworth: but "the box that pops up when tooltips happen"<br>
&lt;gregwhitworth> +1 to masonf<br>
&lt;fremy> masonf: also, pointing out, many sites refuse to use these tooltips<br>
&lt;lea> +1 to masonf too<br>
&lt;fremy> masonf: and these sites accept the trade-off about off-bound positioning<br>
&lt;fremy> masonf: personally, I don't even see that native tooltips are that necessary<br>
&lt;fremy> masonf: I would not mind a single path, custom ones<br>
&lt;fremy> masonf: they would be simpler<br>
&lt;astearns> ack lea<br>
&lt;fremy> astearns: removing is difficult on the web platform, but that's an interesting idea<br>
&lt;fremy> lea: can we get some data about what tooltips can do on native platforms?<br>
&lt;fremy> lea: that would help shape the discussion<br>
&lt;fremy> lea: also, if it behaves like a tooltip, I feel it should be called a tooltip<br>
&lt;fremy> lea: scrollbars were in that list of strange things once, but we resolved that built-in customization is better than wild hacks<br>
&lt;masonf> astearns, the behavior of the title attribute (generating a "tooltip") is not standardized, so we're not really removing something. We're better defining it and making it more developer-friendly.<br>
&lt;emilio> q+<br>
&lt;fremy> lea: mutltiple codepaths are fine on the web platform, like for &lt;button> so I don't buy that objection<br>
&lt;astearns> zakim, close queue<br>
&lt;Zakim> ok, astearns, the speaker queue is closed<br>
&lt;fremy> lea: if we can get rid of the native ones, I don't mind personally<br>
&lt;fremy> lea: eventually, we can probably find constraints<br>
&lt;fremy> lea: most sites that have enough resources to make a choice<br>
&lt;fremy> lea: do not use the native ones<br>
&lt;astearns> ack dbaron<br>
&lt;Zakim> dbaron, you wanted to comment on alt text<br>
&lt;una> +1 will be much easier to build without expanding window bounds and that doesn't sound like a top requirement to support authors here<br>
&lt;fremy> lea: also, I would object about "title" as the name, because "title" was an odd name<br>
&lt;fremy> dbaron: some feedback we once got about alt text in tooltips<br>
&lt;TabAtkins> Basically, webcomics.<br>
&lt;fremy> dbaron: we stopped doing this by default<br>
&lt;astearns> ack emilio<br>
&lt;fremy> dbaron: because alt text was used as a hack, instead of a real description<br>
&lt;fremy> dbaron: so, this change was intentional<br>
&lt;fremy> emilio: multiple codepaths are fine, but also the difficulty of them is important<br>
&lt;lea> q?<br>
&lt;fremy> emilio: for me to become more serious about this, I would like to hear some consensus from implementors that the bound restriction<br>
&lt;lea> emilio: Of course the code path is different for buttons, my point was that from the author side there is precedent for rendering going through a different code path once CSS is applied.<br>
&lt;fremy> emilio: if we get consensus on that, I'm fine with this<br>
&lt;astearns> ack fantasai<br>
&lt;lea> We have "make simple things easy and complex cases possible" in our TAG principles :)<br>
&lt;fremy> fantasai: personally, I agree with lea, we need to bridge the gap between "you control nothing" and "you have to implement javascript, accessibility, etc..."<br>
&lt;lea> s/complex cases/complex things/<br>
&lt;fremy> fantasai: right now we don't have that middle ground<br>
&lt;fremy> fantasai: I also feel like if it looks like a tooltip and behaves like a tooltip, let's call it a tooltip<br>
&lt;fremy> fantasai: and for the content, I think we are ok with using the same text as it would do today<br>
&lt;fremy> fantasai: I think it's fine, ::tooltip should allow you to style it<br>
&lt;fremy> fantasai: given the facts a lot of authors seem fine to keep it in the window bounds, I think it's reasonable<br>
&lt;fremy> fantasai: in terms of positioning, we can punt this for now, and come back to this later<br>
&lt;masonf> +1 to everything fantasai just said.<br>
&lt;lea> also +1 to everything fantasai just said!<br>
&lt;fremy> fantasai: but, globally, I think it's a net benefit if (a) it's easy (b) &lt;missed> (c) accessibility is preserved<br>
&lt;lea> q?<br>
&lt;lea> q+<br>
&lt;miriam> q+<br>
&lt;nicole> q+<br>
&lt;fremy> lea: I would not mind the bounds restrictions to depend on the used styles<br>
&lt;fremy> miriam: quick question<br>
&lt;fremy> miriam: I have seen many a11y recommendations to not use the title attribute<br>
&lt;fantasai> s/&lt;missed>/UA handles positioning and appearance logic so it's not error-prone/<br>
&lt;fremy> miriam: is that an anti-pattern?<br>
&lt;fremy> chrishtr: I have heard the same, it's often much too loud for them<br>
&lt;fantasai> perhaps it should be less loud...<br>
&lt;fremy> astearns: I'm wondering, can we resolve on a ::tooltip pseudo, with a few properties allowed, and figure out the details later in little pieces<br>
&lt;lea> allowlist and window bounds are related, they should be part of the same issue<br>
&lt;masonf> +1<br>
&lt;lea> +1<br>
&lt;fremy> astearns: any direct response to that proposed resolution?<br>
&lt;gregwhitworth> +1<br>
&lt;fremy> astearns: any objection to this?<br>
&lt;bramus> +1<br>
&lt;castastrophe_> Very exciting!<br>
&lt;una> awesome :)<br>
&lt;gregwhitworth> only 23 years<br>
&lt;lea> 🎉<br>
&lt;fremy> RESOLVED: Standardize a ::tooltip pseudo, with a few properties, to style tooltips<br>
&lt;masonf> :-) nice!<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8930#issuecomment-1644333441 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 20 July 2023 17:42:36 UTC