I'm making a Stack Exchange app, and one thing I found pretty cool in the sites API is that it sends us the colors for links and tags, so my apps color is kind of consistent with the sites.

But the site branding color, like orange in Stack Overflow, or red in Server Fault, is not included. I consider that color to be the most important one, so I could use as an "accent color" in my app.

I'm thinking that maybe somebody already thought that, and maybe there is a reason to not to provide this color, but I can't think of one. If that's the case, I really want to know the reason.

P.S.: my app is a personal project to learn Jetpack Compose - https://github.com/vitor-ramos/LiveQuestions


It looks like this color is used in the side menu:

enter image description here enter image description here

So you can retrieve the site's CSS, e.g. https://cdn.sstatic.net/Sites/serverfault/primary.css, parse it and fetch it from the border-right attribute of the .youarehere class:

enter image description here

This side menu is a relative recent change, and API updates have been very rare for a couple of years.

  • This does solve my problem, but I believe I shouldn't rely on that to get the color. The site's devs are free to change their CSS without concerning about breaking other people's stuff, right? – Vitor Ramos Oct 25 '20 at 17:45
  • 1
    It's a workaround, sure, but it's the only thing I can think of right now. I wouldn't put my hope into Stack Exchange adding this information to the API... – Glorfindel Oct 25 '20 at 18:05
  • @VitorRamos .site-header--container background does retrieve the color. – Rob Oct 25 '20 at 18:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .