-
Notifications
You must be signed in to change notification settings - Fork 717
[mediaqueries-5] prefers-interaction-side
media query & interaction-side
property
#10244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
prefers-interaction-direction
media query & interaction-direction
propertyprefers-interaction-direction
media query & interaction-direction
property
I presume this is related to the idea that, if you're holding a smartphone in your right hand, it's easier to access controls on the right and bottom sides, while top/left controls require either an uncomfortable reach or switching to using both hands? If so, I definitely sympathize with the concern, and think there's potential here. However, is there any way to actually detect this? I'm not familiar with whatever APIs might exist. I know that the OSK can be switched to a mode that favors one hand or the other by shifting slightly to one side, but I only ever activate that by accident. The big issue with new user-preference MQs is always going to be the actual detection. It can be the best idea in the world, but if no OS exposes that the user wants it (and the browser doesn't hack their own detection/preference-recording on top), we can't actually hang an MQ off of it. |
@tabatkins Thanks! Yeah, that's part of it, and to better support persons with disabilities. Good call-out on the detection. My thought was to reach out to browsers as well and add support there first, and then work outward on getting that supported natively at the OS level, but perhaps I'm working backward here and should start OS-first. |
I think this is one of the annoying cases that has to be worked at both ends simultaneously. :( |
Gotcha. I'll start reaching out to OS teams to see if I can gain some traction on that end. @argyleink recommended I reach out to Android OS to start, on Google's issue tracker. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Related Android OS issue opened here: https://issuetracker.google.com/issues/336589276 |
@brandonmcconnell Do you see this as a mobile only thing? Or are you expecting desktop users to use this? I ask for clarity. I think you have a good concept here, I'm just not sure of the execution of it. One of the reasons is that while we've seen success with reflow for RWD, we still struggle to get developers to support orientation on native mobile apps. Considering these settings will have multiple variants we will need to convince designers as well. If the designers don't adopt flexible layouts, then this will go nowhere and I don't see them wanting to do this. But the flexible layouts themselves may be an issue. If a site is coded with the navigation on top and the user sets it as preference for the bottom, what does the reading and focus order look like? |
@nattarnoff I've considered the same question. While developers could use this in either desktop or mobile, I could see developers implementing this specifically for touch devices by combining nav {
position: fixed;
top: 0;
}
form#login {
float: left;
}
@media (pointer: coarse) {
@media (prefers-interaction-direction: bottom) and (width < 767px) {
nav {
top: unset;
bottom: 0;
}
}
@media (prefers-interaction-direction: right) {
form#login {
float: right;
}
}
} In terms of OS, prominent device companies like Google/Android and Apple would likely implement this feature exclusively on mobile and tablet devices, at least to start, unless the WCAG makes a solid argument to include it across all device types. I see a case being made for less able persons preferring most interactions to be on one side of the screen to prevent having to move the cursor so far for every interaction. Many applications will inevitably be slow to adopt this, but providing a way for applications to hook into this preference would allow those companies and developers with ample bandwidth to cater to those specific needs, which would be a great convenience to those who need it. Accessibility features like |
I wonder if a better argument can be made for XR than for mobile. Maybe detection (e.g., Apple Vision Pro) is possible but maybe it's only stored in user preferences for the device to start with detection coming as hardware/OS expands sensors. |
@AutoSponge Interesting! I could see this being possibly helpful if implemented in XR/AR as well, though one of the primary use cases would be mobile as that addresses a common problem I and others face when crafting user interfaces. |
@nattarnoff Re designer/developer adoption, specifically your note on low Adoption is important The goal of implementing this feature, as with many accessibility issues, is to capture and expose the preference so designers/developers can tap into it. The next journey will be adoption, which is an equally vital but arguably separate concern. Through education and social efforts, we can work to make these features—and others like them—ones that designers/developers will tap into. TL;DR:
|
@nattarnoff Reading order often remains unchanged when using features like this, and follows the flow of the order of elements in the DOM. For example, the reading order of the content here remains "form ➞ main" regardless of their visually rendered order: <div id="wrapper">
<form id="login">…</form>
<main>
…
</main>
</div> #wrapper {
display: flex;
}
main {
flex: 1;
}
@media (prefers-interaction-direction: right) {
main {
order: -1;
}
} See example: https://codepen.io/brandonmcconnell/pen/NWmozxO/8b53be8b61fbb92d6223e1b70c3d9922 |
Why should |
@ByteEater-pl The problem this solves is less about the flow of content and more about which side of each axis a user prefers interactive elements to be on. There would be no difference between Here are some examples, one per axis:
There are rare instances I can think of where someone may want to query both axes together, so it may be more confusing to allow those to be queried together. This is certainly something I would like to collect more feedback on. One example of why querying both together could be problematic is if someone queries both together to try to set up a corner-specific element without accounting for a use case where someone has no preference set on only one axis, which would be extremely common. .corner-element {
position: fixed;
@media (prefers-interaction-direction: no-preference) { inset: auto 0 0 auto; }
@media (prefers-interaction-direction: top left) { inset: 0 auto auto 0; }
@media (prefers-interaction-direction: top right) { inset: 0 0 auto auto; }
@media (prefers-interaction-direction: bottom left) { inset: auto auto 0 0; }
@media (prefers-interaction-direction: bottom right) { inset: auto 0 auto 0; }
} This is a non-issue if—like with If the system default were In cases like the example above, it might be simpler to use one rule per axis: .corner-element {
position: fixed;
@media (prefers-interaction-y: no-preference) or (prefers-interaction-y: bottom) {
bottom: 0;
}
@media (prefers-interaction-y: top) {
top: 0;
}
@media (prefers-interaction-x: no-preference) or (prefers-interaction-x: right) {
right: 0;
}
@media (prefers-interaction-x: left) {
left: 0;
}
} We can simplify further by setting defaults on the element styles itself, outside the queries: .corner-element {
position: fixed;
bottom: 0;
right: 0;
@media (prefers-interaction-y: top) {
top: 0;
bottom: auto;
}
@media (prefers-interaction-x: left) {
left: 0;
right: auto;
}
} I anticipate most developers using It would still be vital to include |
prefers-interaction-direction
media query & interaction-direction
propertyprefers-interaction-side
media query & interaction-side
property
If this is about which side of the page interactive elements should be on, that's a very different thing from a "direction of flow" preference which is what this sounds like. Renaming; we can bikeshed more later but at least let's get the basic concept up front. |
@fantasai Thanks! Yes, I can see how that could be confusing. This is more about the |
I'd like to mention an additional supporting use (particularly for including top and bottom) case I've come across for several years (partly as a vision-impaired person, but I think this generalises pretty well). We have had widescreen (and now even wider-screen) monitors for some time, and a lot of vertical screen space is wasted by things like toolbars that run along the top/bottom of apps. For me, this is exacerbated by my use of UI scaling to increase the size of UI controls and text - the wasted vertical space gets pretty big at times. I would love to be able to move some toolbars to the sides instead. There are examples in some GUI environments where you can place things like taskbars/panels on the top/bottom or either side - far fewer extend this to general app toolbars too. Though some environments and applications let you position toolbars on any of the four sides. E.g. Inkscape (screenshots page) even automatically puts some toolbars on the left/right (rather than top/bottom) according to screen space, and it can position tool pallettes/docked windows on the left or right. It would be great if mainstream operating systems and their standard GUI widget libraries would offer this flexibility, including for in-app toolbars. The web could leapfrog other platforms here. We discussed this on the Accessible Platform Architectures WG call today (thanks to @AutoSponge for the 'heads up' about this conversation), though this comment represents my personal (albeit I hope helpful as a datum point) perspective. |
Uh oh!
There was an error while loading. Please reload this page.
Introduction
This proposal introduces a new media query,
prefers-interaction-direction
, which allows web developers to adapt their layouts and user interfaces based on the user's preferred interaction direction. The media query informs the website about the optimal placement of interactive elements, such as login forms and navigation bars, to enhance user experience and accessibility.This could be very helpful to users for several reasons:
Syntax
The
prefers-interaction-direction
media query accepts the following values:left
right
top
bottom
The media query can be used as follows:
Combining Interaction Directions
The
prefers-interaction-direction
media query allows for combining interaction directions to target specific user preferences.For example, these two would be equivalent:
This feature enables web developers to create more tailored user experiences based on the combination of the user's preferred interaction directions.
Overriding the User Preference
To provide flexibility and control to web developers, a new CSS property,
interaction-direction
, is introduced to override the user's preferred interaction direction. This property functions similarly to thecolor-scheme
property, which overrides theprefers-color-scheme
media query.The
interaction-direction
property accepts the same values as theprefers-interaction-direction
media query, allowing web developers to explicitly set the interaction direction for specific elements.Any of the "Single-direction values" or "Direction-paired values" listed above could also be used with
only
to override default UA behavior.One consideration is whether "Direction-paired values" should support
only
used once for both values or if it should be used per value as needed.Prior Art
References and inspiration
https://www.smashingmagazine.com/2016/09/the-thumb-zone-designing-for-mobile-users/
https://www.smashingmagazine.com/2019/08/bottom-navigation-pattern-mobile-web-pages/
https://www.scotthurff.com/posts/how-to-design-for-thumbs-in-the-era-of-huge-screens/
https://www.scotthurff.com/posts/facebook-paper-gestures/
https://konsav.medium.com/-55aba8ed3859
https://www.uxmatters.com/mt/archives/2013/02/how-do-users-really-hold-mobile-devices.php
https://www.lukew.com/ff/entry.asp?1927
Conclusion
The introduction of the
prefers-interaction-direction
media query and theinteraction-direction
property would empower developers to create more dynamically responsive and accessible user interfaces. By adapting to the user's preferred interaction direction, websites can enhance the user experience and cater to diverse user preferences and needs.The text was updated successfully, but these errors were encountered: