Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adds default styles for [popover] #17945

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

Open
brandonmcconnell wants to merge 1 commit into tailwindlabs:main
base: main
Choose a base branch
Loading
from brandonmcconnell:default-popover-styles

Conversation

Copy link
Contributor

@brandonmcconnell brandonmcconnell commented May 9, 2025
edited
Loading

This PR addresses existing preflight styles that break the default positioning of popover elements, as well as add some sensible default colors to override those set by the UA by default

  • Restores default centering: Implements margin: auto to maintain the expected centering for popovers.
  • Sensible default colors:
  • Sets color: inherit for more predictable text styles.
  • Sets background-color: transparent for easier customization.

The browser's defaults for these colors are canvastext and canvas color, respectively, which is another option (to allow the UA styles to take precedence), but I think the inherit/transparent styles are more customizable by default, similar to how borders are removed from form controls when Tailwind CSS applies appearance: none to form controls, by default.

Minimal repro: https://play.tailwindcss.com/jjyvteYH0n

@brandonmcconnell brandonmcconnell requested a review from a team as a code owner May 9, 2025 07:42
Copy link
Member

@brandonmcconnell Hey! Thanks for the PR but I do think we should handle [popover] the same as <dialog>. For the latter we've been removing the margin explicitly and even mention it in the upgrade guides: #16372.

For colors and background colors, <dialog> also falls back to the default canvastext/canvas colors right now: https://play.tailwindcss.com/9Y4nGN0Kyk

So I wonder if the move here is to also mention that [popover] has its margin removed in the upgrade guide instead and not make any changes in preflight (these would be considered breaking changes too so landing them requires more care).

Copy link
Contributor Author

brandonmcconnell commented May 19, 2025
edited
Loading

So the browser default styling actually breaks the styling (specifically inset) for non-dialog popovers.

Even if you were to change just the inset, I think that would be a huge improvement. Una Kravets has been fighting for this specifically:
https://x.com/una/status/1917662266427859202?s=46&t=spTB6QeQp6pscIFtkaMK7w

Something like this:

[popover]:not(dialog) {
 inset: auto;
}
GaneshVarma1 reacted with heart emoji

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /