It seems that Databricks implements its dark mode by applying the invert filter so that all colors are reversed. This is problematic if one wants to create some sort of html widget or rich output since this filter is passed down to the result of displayHTML. Then your output can look good in either light mode or dark mode but not both.
Is there a way to circumvent this or detect whether the editor is in light or dark mode with javascript from within the output cell? Since the output of displayHTML is sandboxed inside an iframe I see no direct way to access parent classes or to negate them.
Example:
displayHTML('<div style="color: red;">Hello</div>')
This looks red in light mode but teal in dark mode. I've tried !important, filter: none, color-scheme: light; etc but nothing seems to work.