Skip to content
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

[tooltip] Change default Tooltip position to "top" #558

Open
lukaselmer opened this issue Aug 30, 2024 · 6 comments
Open

[tooltip] Change default Tooltip position to "top" #558

lukaselmer opened this issue Aug 30, 2024 · 6 comments
Labels
component: tooltip This is the name of the generic UI component, not the React module! waiting for 👍 Waiting for upvotes

Comments

@lukaselmer
Copy link

lukaselmer commented Aug 30, 2024

Summary

Tooltips should be placed by default on top for touch devices.

interface TooltipProps {
  // [...]
  /**
   * Tooltip placement.
   * @default 'top' for touch devices, 'bottom' otherwise
   */
  placement?:
    | 'bottom-end'
    | 'bottom-start'
    | 'bottom'
    | 'left-end'
    | 'left-start'
    | 'left'
    | 'right-end'
    | 'right-start'
    | 'right'
    | 'top-end'
    | 'top-start'
    | 'top';
  // [...]
}

Possible implementation:

import { Tooltip as MuiTooltip, TooltipProps, useMediaQuery } from '@mui/material'

export function Tooltip(props: TooltipProps) {
  const isTouch = useMediaQuery('(pointer: coarse)')
  const placement = props.placement ?? (isTouch ? 'top' : undefined)
  return <MuiTooltip {...props} placement={placement} />
}

Examples

https://m3.material.io/components/tooltips/guidelines#57286ec2-db8e-4699-aa43-0ca11cab0bb5

image image

Motivation

A (plain) tooltip is hidden under the finger which is touching the screen. So the finger has to be moved, or the finger has to be flipped upside down to view the tooltip. Sometimes, the users don't even see the tooltip, because it is hidden under their finger.

Search keywords: tooltip touch position

Search keywords:

@lukaselmer lukaselmer added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 30, 2024
@oliviertassinari oliviertassinari added the component: tooltip This is the name of the generic UI component, not the React module! label Aug 30, 2024
@oliviertassinari oliviertassinari transferred this issue from mui/material-ui Aug 30, 2024
@oliviertassinari oliviertassinari changed the title Change default of Tooltip position to "top" (at least for touch devices) [tooltip] Change default of Tooltip position to "top" (at least for touch devices) Aug 30, 2024
@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 30, 2024

On mobile, Google Drive behaves like this indeed, it makes sense to me:

SCR-20240831-btrk

On desktop, this sounds like an absurd default, e.g.

SCR-20240831-bpqz

https://m3.material.io/components/tooltips/guidelines#57286ec2-db8e-4699-aa43-0ca11cab0bb5

@atomiks
Copy link
Contributor

atomiks commented Sep 2, 2024

This is already the case for the Tooltip in the new Base UI. However, Tooltip intentionally doesn't work for touch input in the new Base UI. Alternatives will be documented. (cc: @colmtuite)

absurd default

Why is it absurd?

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 2, 2024

Why is it absurd?

I assumed that 99% of the websites show tooltips on desktops below the target and so doing something different would confuse end-users.

Alternatives will be documented.

The problem is that to have an ejectable source for Material UI, we need the logic abstracted somewhere into an npm package. If not in Base UI, then OK, It could be:

  • @base-ui/react tooltip desktop
  • @material-ui/base wrapped version to with the mobile support (Android like UX)
  • @material-ui/md3 CSS in npm or ejected

@colmtuite
Copy link
Contributor

I assumed that 99% of the websites show tooltips on desktops below the target

Not sure where you're getting that idea? The standard default (that most tooltips on the web outside of a header bar follows) is above the trigger. It's also the default for Radix and RA. So top makes sense as the default.

The problem is that to have an ejectable source for Material UI

We'll figure this out later, as we begin building v7 on top of Base UI.

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 2, 2024

Not sure where you're getting that idea? The standard default (that most tooltips on the web outside of a header bar follows) is above the trigger. It's also the default for Radix and RA.

@colmtuite Right ok, I got spoiled by Material Design (Google UIs) and GitHub UI that uses bottom. The placement between top and bottom depends: https://open-ui.org/components/tooltip.research/.

Design system where tooltip is at the bottom:

We'll figure this out later

👍

@mj12albert mj12albert changed the title [tooltip] Change default of Tooltip position to "top" (at least for touch devices) [Tooltip] Change default Tooltip position to "top" Feb 19, 2025
@mj12albert mj12albert added the waiting for 👍 Waiting for upvotes label Feb 19, 2025
@mj12albert mj12albert removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 19, 2025
@mj12albert mj12albert changed the title [Tooltip] Change default Tooltip position to "top" [Tooltip] Change default Tooltip position to "top" Feb 19, 2025
@mj12albert
Copy link
Member

Let's make this "waiting for upvotes" in the mean time!

If you want to see this implemented, please add a 👍🏼 reaction to the issue's description ~

@oliviertassinari oliviertassinari changed the title [Tooltip] Change default Tooltip position to "top" [tooltip] Change default Tooltip position to "top" Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: tooltip This is the name of the generic UI component, not the React module! waiting for 👍 Waiting for upvotes
Projects
None yet
Development

No branches or pull requests

5 participants