ui: [BUG] Blurry Content on Low-Resolution Screens with Overflow-Auto in AlertDialog/Dialog Components
Description
The content within AlertDialog/Dialog components becomes blurry on low-resolution screens when the overflow-auto property is in effect. This issue appears to be related to the use of translate on DialogContent. The blurring effect is noticeable when the content exceeds the container size, suggesting that the issue may be linked to subpixel rendering and the rasterization process on low-resolution displays.
Environment
- Tailwind CSS version: 3.4.1
- Browser and version: Chrome 119.0.6045.200
- Screen resolution: 1920*1080
Steps to Reproduce
- Create an
AlertDialog/Dialogcomponent withoverflow-autoonDialogContent. - Add enough content inside the
DialogContentto cause overflow. - Observe the content on a low-resolution screen.
Expected Behavior
Content should remain crisp and clear, without any blurring, regardless of screen resolution.
Actual Behavior
Content becomes blurry on low-resolution screens when overflow-auto is applied to DialogContent with a translate transform.
Additional Information
- The issue seems to be exacerbated by the
translatetransform, potentially due to subpixel positioning on low-resolution screens. - It is observed that the blurring effect is not present on high-resolution screens, which suggests that pixel density plays a role in the problem.
Possible Solutions
- Avoiding the use of
translateon elements withinoverflow-autocontainers. - Ensuring that element dimensions and translate values are set to even numbers to align with the pixel grid.
- Using
flexboxorgridlayouts for centering instead oftranslate.
I am looking forward to any suggestions or workarounds for this issue. Thank you for your assistance!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 16
For those in need, here’s the updated original component to use flexbox for centering, instead of translating, which removes the bluriness. The open animation has also been adjusted, so it’s the same as before.
The perfect solution is
transform: translate(round(-50%, 1px), round(-50%, 1px))While this does resolve the blurriness, I’ve found that the closing animation no longer works after wrapping
DialogPrimitive.Contentin adiv😕Changing
translate-y-[-50%]totranslate-y-[-53%]indialog.tsxcomponent file removed the blurriness in most cases. it still happens when i change focus on a TinyMCE input I have within the dialog.To retain the close animation, you can wrap the
DialogPrimitive.Contentwithin theDialogOverlay:Thanks! But a little trick is to use a grid and
place-content-centerI’m still experiencing this issue on a Windows machine with display scaling set to a value higher than 100% – any chance the issue could be re-opened?