Skip to content

The overlay CSS property #777

Open
Open

Description

@josepharhar

Request for Mozilla Position on an Emerging Web Specification

Other information

The CSS Spec is done. There are additional tie-ins to HTML and fullscreen:

Here is the CSSWG issue: w3c/csswg-drafts#8189

Activity

  1. zcorpan commented on Apr 13, 2023

    @zcorpan
    Member
  2. SebastianZ commented on Apr 19, 2023

    @SebastianZ
    Contributor

    The CSS Spec is done.

    As Alan Stearns points out in w3c/csswg-drafts#8730, there's still an open discussion.

    Sebastian

  3. itpropro commented on Oct 5, 2024

    @itpropro

    w3c/csswg-drafts#8730 was resolved over a year ago, has the position changed or are there plans to work on https://bugzilla.mozilla.org/show_bug.cgi?id=1841456?

  4. birtles commented on Oct 7, 2024

    @birtles
    Member

    For what it's worth, I think it's weird that this can only be set by transitions and not animations. If we want to keep that behavior, I think we need to specify exactly how that works.

    For example, if a CSSTransition object has no owning element, does the overlay property specified on any associated keyframe effect still have an effect?

    The fact that only transitions can set it is only defined in non-normative text (although later normative text assumes it to be the case) and the decision to make ignoring transitions in some circumstances undefined is going to cause interop issues:

    User agents may, at their discretion, remove a running transition on overlay. The conditions for this are intentionally undefined.

    For example, does pausing such a transition cause it to be ignored? What about seeking it?

  5. itpropro commented on Oct 8, 2024

    @itpropro

    For what it's worth, I think it's weird that this can only be set by transitions and not animations. If we want to keep that behavior, I think we need to specify exactly how that works.

    For example, if a CSSTransition object has no owning element, does the overlay property specified on any associated keyframe effect still have an effect?

    The fact that only transitions can set it is only defined in non-normative text (although later normative text assumes it to be the case) and the decision to make ignoring transitions in some circumstances undefined is going to cause interop issues:

    User agents may, at their discretion, remove a running transition on overlay. The conditions for this are intentionally undefined.

    For example, does pausing such a transition cause it to be ignored? What about seeking it?

    I think as it is currently only used in a very specific context (Popover API, allow-discrete) and setting it by a transition property basically enables animating it, these use cases can be described quite clearly.
    The user agent setting it is by the spec also reserved for the specific use case of preventing potential abuse scenarios. This would require a specific list of conditions to specify what would be considered as abuse.
    I haven't looked at the implementation in Chromium, but I would assume this work has already been done in their implementation.

  6. birtles commented on Oct 8, 2024

    @birtles
    Member

    I don't doubt the utility of this-I use it myself. I'm just saying this needs spec work/discussion.

  7. moved this from Unscreened to Needs assignees in standards-positions reviewon Oct 10, 2024
  8. emilio commented on Oct 15, 2024

    @emilio
    Collaborator

    I think I agree with @birtles, this in general feels very narrowly scope.

    However I think it is well defined how it works in terms of animations unless I'm missing something?

    In particular, it's defined to be * { overlay: none !important } at the UA-stylesheet level, which overrides animations, right?

  9. birtles commented on Oct 15, 2024

    @birtles
    Member

    However I think it is well defined how it works in terms of animations unless I'm missing something?

    In particular, it's defined to be * { overlay: none !important } at the UA-stylesheet level, which overrides animations, right?

    Yeah, I think you're right (since animations without an owning element target the animations level of the cascade (ref)).

    That said, I still think this should be available to regular animations too since my experience with modal dialogs has shown transitions are sometimes not sufficient for outro animations (e.g.).

    I'm also a bit concerned the deliberately undefined heuristics for ignoring transitions are possibly going to cause interop headaches.

    It's also not entirely trivial to come up with good heuristics. For example, pausing a transition could cause it to persist its effect forever which could be abused. Ignoring paused transitions, however, would make DevTools less useful since you wouldn't be able to inspect outro animations. Likewise for transitions whose playback rate is slowed down significantly, or transitions that are periodically seek-ed backwards such that they never end.

  10. moved this from Needs assignees to Needs proposed position in standards-positions reviewon Oct 15, 2024
  11. tabatkins commented on Oct 15, 2024

    @tabatkins

    Right. Per the spec, nothing prevents you from applying an 'overlay' animation, it's just not going to do anything, due to the property always having a value set in the UA-important cascade origin. Due to the way transitions work, they'll activate and apply even between UA-important value changes, but animations apply between the author and author-important cascade origins, so they'll be ignored.

    That said, I still think this should be available to regular animations too since my experience with modal dialogs has shown transitions are sometimes not sufficient for outro animations

    Without some additional magic, it's not possible to allow something in animations but not in normal properties, so we'd need some extra hand-waving there. Even if we did that, tho, it would still allow authors to keep things in the top layer indefinitely. (The spec uses the 'overlay' value as part of its logic on when to remove something from the top layer.) We'd have to invoke the "kick it out anyway" heuristic more aggressively, whereas currently it's something that should only trigger when you're doing something weird.

    I'm also a bit concerned the deliberately undefined heuristics for ignoring transitions are possibly going to cause interop headaches.

    It's completely undefined at the moment to allow exploration; we'd be happy to add some actual rules based on implementation experience. The expectation, tho, is that it would only get applied to "weird" cases - a transition lasting many seconds, for example. If your "leaving the top layer" animation is >15s long, you're doing something incredibly weird.

    It's also not entirely trivial to come up with good heuristics.

    This is a big part of why we haven't specified them in detail yet. For example, I could imagine the heuristic allowing them to persist indefinitely if DevTools is open.

  12. birtles commented on Oct 16, 2024

    @birtles
    Member

    That said, I still think this should be available to regular animations too since my experience with modal dialogs has shown transitions are sometimes not sufficient for outro animations

    Without some additional magic, it's not possible to allow something in animations but not in normal properties, so we'd need some extra hand-waving there. Even if we did that, tho, it would still allow authors to keep things in the top layer indefinitely. (The spec uses the 'overlay' value as part of its logic on when to remove something from the top layer.) We'd have to invoke the "kick it out anyway" heuristic more aggressively, whereas currently it's something that should only trigger when you're doing something weird.

    Yeah, I can see that would be difficult. Maybe it's ok for overlay to only be animatable via transitions initially and we can explore ways to expand that later.

    In my case, I was building a drawer component using a modal <dialog> and transitions were an awkward fit for the outro animation. (From memory, at least one issue was the duration of the outro animation varies based on the computed height of the drawer.) Instead, I ended up blocking close requests, running the outro animation using Web Animations, then closing the dialog when they complete—awkward and error prone but maybe good enough for now.

  13. tabatkins commented on Oct 16, 2024

    @tabatkins

    I'll say I definitely sympathize with the use-case; the fact that you have to coordinate an outro animation with the transition is definitely bad. It's just weighed against the confusion potential of 'overlay' not really doing anything for authors; if it was settable, all they could do would be (a) delay an element from leaving the top layer (by setting overlay:auto before it leaves), or (b) force an element in the top layer list to not render in the top layer (by setting overlay:none while it's in the top layer list). In all other situations it would do nothing regardless of value, and that's weird.

    All around it's kinda a weird thing, unfortunately.

  14. emilio commented on Nov 9, 2026

    @emilio
    Collaborator

    I think the general problem space is real, but I think we should just fix the top layer exit to either be easier to hook into (e.g. via something in beforetoggle) or something along those lines.

    The overlay design doesn't quite work, see also w3c/csswg-drafts#14697.

    So propose negative.

  15. moved this from Needs proposed position to Position is proposed in standards-positions reviewon Nov 9, 2026
  16. josepharhar commented on Nov 9, 2026

    @josepharhar
    Author

    easier to hook into (e.g. via something in beforetoggle)

    Does this require script? I think this should stay in CSS. What if we used transition: display allow-discrete as an opt-in to make a top layer exit animation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Fields

Priority

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions