Skip to content

Support more PyData theme colors for badges #215

Closed

Description

@user27182

Context

I have found that the existing dark and light colors have low-contrast when viewing a site with the dark and light themes applied, respectively, and are therefore hard to see/read. E.g. see this badge :

image
from pyvista/pyvista#6475.

I went looking for an alternative, but found that dark and light are the only grayscale options with outlines supported by Sphinx Design: https://sphinx-design.readthedocs.io/en/latest/badges_buttons.html

Proposal

Additional colors are available from the PyData theme:
https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/styling.html#color-variables

Something like the surface and on-surface colors might be good alternatives since these change with the theme.

Perhaps all the other PyData theme colors could be supported as well.

Tasks and updates

No response

Activity

  1. added
    enhancement
    on Aug 8, 2024
  2. user27182 commented on Aug 8, 2024

    @user27182
    ContributorAuthor

    Looks like there are three undocumented colors: muted, black, and white

    SEMANTIC_COLORS = (
    "primary",
    "secondary",
    "success",
    "info",
    "warning",
    "danger",
    "light",
    "muted",
    "dark",
    "white",
    "black",
    )

    Here's what all the colors look like (including undocumented ones) with the light and dark PyData theme applied:
    image

    Based on this it looks like muted produces the best results for what I'm looking for, as the outline version is clearly visible with either the dark or light theme.

    So, at the very least, this issue is a documentation issue. It would be good to update the docs to include the three undocumented colors muted, black, and white.

  3. chrisjsewell commented on Nov 10, 2026

    @chrisjsewell
    Member

    Thanks for the investigation! The undocumented muted, white and black colours you found are now documented (#216). For colours that adapt to a theme's light/dark mode, every semantic colour is a CSS variable (--sd-color-dark, --sd-color-dark-text, ... see the CSS variables page), so you can map them to PyData's palette in a custom stylesheet, e.g. under html[data-theme="dark"] { --sd-color-dark: var(--pst-color-on-surface); }. Building theme-specific palettes into sphinx-design is out of scope, so I'm closing this as fixed by the docs update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions