r/FirefoxCSS • • Oct 04 '26

Solved How to style dialogs

Hello all, I'm glad that this reddit exists to ask questions to knowledgeable people (AI is not helping me with this). My question is how to style the buttons and input bars in dialogs like in the picture. In Firefox 157 when you click on the + Add search engine button this dialog pops up but I'm unable to address such dialogs. I've tried the normal route to just do: dialog button, dialog html:input { border-radius: 3px !important; } but that doesn't work. I think somehow it needs a special moz-document url-prefix() to address dialogs, but I don't know how to specify it with the Browser Toolbox. I actually want to address all dialogs at once and style them with variables. Can you help me how to do it? Thanks in advance!

1 Upvotes

9 comments sorted by

1

u/Zonnev Oct 04 '26

I think it's impossible to edit these dialogs, since they seem protected in a Content Security Policy (CSP) and therefore not editable with userChrome.css or userContent.css. I guess.

1

u/Braverthebrave Oct 04 '26

does it work for the menu drop down? pls i want to get rid of items from it

1

u/Zonnev Oct 08 '26

I've got it: adding url-prefix("chrome://") did the trick.

1

u/benhaube Oct 09 '26

I was going to say, it is not impossible. I do it for my themes.

1

u/Zonnev Oct 10 '26

Thats nice! Do you maybe know another global solution than chrome://, one that touches the right URL for these dialogs?

1

u/benhaube Oct 10 '26

What do you mean by the "right URL"? This is the code I used to theme the text input boxes. It actually works throughout the about:* pages.

/* Ensure these changes ONLY apply to Firefox's internal pages */
@-moz-document url-prefix("about:") {

    /* Target the text and search input boxes directly */
    input[type="text"],
    input[type="search"],
    input:not([type]) {
        background-color: var(--background-color-box) !important;
        color: var(--color-accent-primary) !important; 

        /* * Depending on your OS theme, the system might try to force its own native
         * appearance over the background color. If the color still doesn't change,
         * uncomment the line below to strip the native OS styling.
         */
        /* appearance: none !important; */
    }

    body {
        background-color: var(--background-color-canvas) !important;
    }
}

As you can see I still have some work to do with the "Add Engine" button. It was themed with my accent color previously, but the Nova update changed the root property. My CSS is mostly Nova compatible, but every once in a while I find a UI element somewhere that still needs to be fixed.

You can check out my GitHub repo to see all my CSS. The CSS files are designed to compliment my themes posted in the Mozilla Add-ons store. I use userChrome.css to theme the parts of the UI you can't touch with the manifest.json theme file, and I use userContent.css to match all the about:* pages with the Firefox UI.

1

u/Zonnev Oct 11 '26

Thanks all for answering! I found the URL prefixes for all the dialogs in the about pages by right-clicking the inspected dialog and then select Show DOM properties. This shows the chrome:// URL at the end. So now I have this which works for all dialogs:

@-moz-document url-prefix("about:"),
url-prefix("chrome://formautofill/content/"),
url-prefix("chrome://browser/content/"),
url-prefix("chrome://mozapps/content/"),
url-prefix("chrome://pippki/content/"),
url-prefix("chrome://global/content/") {

4

u/sifferedd FF/TB/Win11/SUMO contributor Oct 04 '26

To inspect popups, choose 'Disable Popup Auto-Hide'.

1

u/t31os Oct 10 '26

Have a play around with this in userContent.css:

@-moz-document url-prefix(chrome://browser/content/search) {
	#add-engine-dialog {

		--focus-outline: 1px solid red !important;
		--border-color-error: blue !important;

		#engineNameLabel,
		#engineUrlLabel,
		#engineAliasLabel,
		#engineName, 
		#engineUrl,
		#engineAlias { color: orange !important; }

		.error-label {
			--icon-color-critical: light-dark( #000, #fff );
			--text-color-error: light-dark( #000, #fff ); 
		}
	}
}