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

[material-ui][Tooltip] Tooltip/popper styles are not applying through direct sx styles in Tooltip component #43134

Closed
jvega190 opened this issue Jul 31, 2024 · 3 comments
Labels
component: Popper The React component. See <Popup> for the latest version. component: tooltip This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material

Comments

@jvega190
Copy link

jvega190 commented Jul 31, 2024

Steps to reproduce

Link to live example

Steps:

  1. See how the styles applied to tooltip or popper are not applying in the link above

Current behavior

No response

Expected behavior

No response

Context

Styles don't apply when using the Tooltip sx prop. It does work using slotProps and add the sx styles on the tooltip

<Tooltip
   ...
   slotProps={{ tooltip: { sx: { ... } } }}
/>...

(the code above works)

The problem is, if I want to use the styled API, I'm not able to override the tooltip/popper styles.

Your environment

npx @mui/envinfo
Browser: Google chrome 127.0.6533.72 on ubuntu 22.04

Search keywords: tooltip, styles, popper

@jvega190 jvega190 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 31, 2024
@MeetBagda
Copy link

Steps to reproduce

Link to live example

Steps:

  1. See how the styles applied to tooltip or popper are not applying in the link above

Current behavior

No response

Expected behavior

No response

Context

Styles don't apply when using the Tooltip sx prop. It does work using slotProps and add the sx styles on the tooltip

<Tooltip
   ...
   slotProps={{ tooltip: { sx: { ... } } }}
/>...

(the code above works)

The problem is, if I want to use the styled API, I'm not able to override the tooltip/popper styles.

Your environment

npx @mui/envinfo
Search keywords: tooltip, styles, popper

Hey @jvega190,

The reason behind this issue is Tooltip component is structured in a way that the sx prop doesn't directly target the desired elements.

It can be solve by using the slotProps

<Tooltip
  slotProps={{
    tooltip: { sx: { backgroundColor: 'red', color: 'white' } },
    popper: { sx: { backgroundColor: 'blue' } }
  }}
>
  ...
</Tooltip>

you can customise the Tooltip as well but this approach allows granular control over Tooltip and Popper styles.

@zannager zannager added component: tooltip This is the name of the generic UI component, not the React module! component: Popper The React component. See <Popup> for the latest version. package: system Specific to @mui/system labels Aug 1, 2024
@ZeeshanTamboli
Copy link
Member

It is expected. See #28679 and #11467. As for styling using the styled API, did you take a look at https://mui.com/material-ui/integrations/interoperability/#portals.

@ZeeshanTamboli ZeeshanTamboli removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 3, 2024
@ZeeshanTamboli ZeeshanTamboli added package: material-ui Specific to @mui/material and removed package: system Specific to @mui/system labels Aug 3, 2024
@ZeeshanTamboli ZeeshanTamboli changed the title [MUI Tooltip] Tooltip/popper styles are not applying through direct sx styles in Tooltip component [material-ui][Tooltip] Tooltip/popper styles are not applying through direct sx styles in Tooltip component Aug 3, 2024
@jvega190
Copy link
Author

jvega190 commented Aug 6, 2024

Thanks, noted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Popper The React component. See <Popup> for the latest version. component: tooltip This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

No branches or pull requests

5 participants