Skip to content

Conversation

rouk1
Copy link
Contributor

@rouk1 rouk1 commented Oct 2, 2025

Closes #30357

This PR changes the way color are chosen when displaying an estimator as an HTML representation.
The strategy is the following:

  1. check if user uses vs code and their theme declares as light or dark
  2. check if user uses jupyter in dark or light mode
  3. check the default color of text that the element inherits from its hierarchy, use a luma threshold to determine if it dark or light
  4. fallback to system media query

UI previews:

VS code light
Screenshot 2025-10-02 at 13 52 24

VS code dark
Screenshot 2025-10-02 at 13 52 48

VS code dark high crontrast
Screenshot 2025-10-02 at 13 53 12

Copy link

github-actions bot commented Oct 2, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 931dbfd. Link to the linter CI: here

@glemaitre glemaitre changed the title fix: Estimator HTML repr force dark or light color FIX estimator HTML repr force dark or light color Oct 2, 2025
@ogrisel
Copy link
Member

ogrisel commented Oct 2, 2025

This looks good to me, but we do not have infrastructure for automated non-regression testing for this kind of fixes. Setting up some WebDriver based user testing could be a good idea (famous last words) but should better be deferred to a follow-up PR.

@jeremiedbb
Copy link
Member

check if user uses jupyter in dark or light mode

I tested that case and it works as expected

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested in VS Code and application that embed the estimator and it works as expected

@ogrisel
Copy link
Member

ogrisel commented Oct 2, 2025

Actually it does not look similar to the preview of the description of the PR for me:

image

@ogrisel
Copy link
Member

ogrisel commented Oct 2, 2025

Actually when not unfolding the inner element, this is fine as in the description so this is another unrelated problem.

@ogrisel ogrisel merged commit 72a3122 into scikit-learn:main Oct 2, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTML display rendering poorly in vscode "Dark High Contrast" color theme
4 participants