question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: How does FlatSVGIcon dark mode recoloring work?

See original GitHub issue

When I use a FlatSVGIcon with fill="#6E6E6E" (copied from the icons in the demo), it changes color depending on whether the theme is dark or light (I like that). When I use fill="#000000", it does not. When I download a raw Material icon that doesn’t have a fill specified at all, it is always black. How does it work, what is the underlying mechanism, where is it configured? Is there a documentation for that? Is there a common place where such things are documented (maybe the Demo might be a good spot)?

Thank you.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
DevCharlycommented, Oct 25, 2021

FlatSVGIcon maps only some colours. They are defined in enum FlatIconColors.

The idea is to use only this well defined set of colors in SVG icons and then they are replaced at runtime to dark variants or to other theme colors. Then a single SVG icon (light variant) can be used for dark themes too. IntelliJ Platform uses this mechanism to allow themes to change IntelliJ Platform icons.

The colors are based on IntelliJ Platform Action icons and Noun icons.

You can change/extend the color mapping. Either per icon: see FlatSVGIcon.setColorFilter() Or globally for all icons: see FlatSVGIcon.ColorFilter.getInstance()

0reactions
DevCharlycommented, Dec 31, 2021

@howudodat that is a good solution.

is there a preferred property to use to get the highlight color used by the different themes

No. IntelliJ themes are converted from JSON files and do not have such a property. In FlatLaf 2.x core themes there are variables, but they are not accessible via UIManager:

https://github.com/JFormDesigner/FlatLaf/blob/e5956900ea5413fc0e879c0a808272b988cc51c5/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties#L62-L75

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change to dark or color mode on your Android device
On your phone, open the Settings app. Tap Display. Turn Dark theme on or off. Tip: Dark theme can make your screen easier...
Read more >
Dark Mode — Working with Color Systems | by Søren Clausen
Since we defined roles for every single color, it's simple to assign new colors to all of the roles, and instantly we will...
Read more >
How can I make Photoshop menus dark? - Super User
In the pane on the right you'll see various keys, representing UI elements that can be recolored. Most of them (seemingly) won't work...
Read more >
How popular is Dark Mode? | Apple Developer Forums
Does anyone know what percent of iOS user use Dark Mode as their defauklt? ... of lightness and color in my work, so...
Read more >
TOPdesk Operator Recoloring - GitHub Pages
You can completely adjust any theme to your needs. See below for instructions on how to customize the theme to your liking. Default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found