Skip to content

add custom_css param to theme class#12871

Merged
hannahblair merged 17 commits intomainfrom
theme-custom-css
Mar 18, 2026
Merged

add custom_css param to theme class#12871
hannahblair merged 17 commits intomainfrom
theme-custom-css

Conversation

@hannahblair
Copy link
Copy Markdown
Collaborator

@hannahblair hannahblair commented Feb 9, 2026

Description

Allows embedding custom css into generated themes via a custom_css param on the ThemeClass object. The custom_css is appended at the of the theme CSS output at /theme.css, so will override any theme variable.

  • to_dict() now also includes gradio_version so themes loaded from HF can warn if there's a version mismatch (comparing major.minor)
  • also adds a CSS variables reference guide generated by scripts/generate_css_vars_docs.py

Closes: #13038
Closes: #13037
Closes: #13039

AI Disclosure

We encourage the use of AI tooling in creating PRs, but the any non-trivial use of AI needs be disclosed. E.g. if you used Claude to write a first draft, you should mention that. Trivial tab-completion doesn't need to be disclosed. You should self-review all PRs, especially if they were generated with AI.

  • I used AI to... [fill here]
  • I did not use AI

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Testing and Formatting Your Code

  1. PRs will only be merged if tests pass on CI. We recommend at least running the backend tests locally, please set up your Gradio environment locally and run the backed tests: bash scripts/run_backend_tests.sh

  2. Please run these bash scripts to automatically format your code: bash scripts/format_backend.sh, and (if you made any changes to non-Python files) bash scripts/format_frontend.sh

@hannahblair hannahblair changed the title (testing) add custom css param to theme class (testing) add custom_css param to theme class Feb 9, 2026
@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

gradio-pr-bot commented Feb 9, 2026

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website building...
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/099f06a95df67552c7b247c278e967c606b052af/gradio-6.9.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@099f06a95df67552c7b247c278e967c606b052af#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/099f06a95df67552c7b247c278e967c606b052af/gradio-client-2.1.0.tgz

@gradio-pr-bot
Copy link
Copy Markdown
Collaborator

gradio-pr-bot commented Feb 9, 2026

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
gradio minor

  • add custom_css param to theme class

‼️ Changeset not approved. Ensure the version bump is appropriate for all packages before approving.

  • Maintainers can approve the changeset by checking this checkbox.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@hannahblair hannahblair changed the title (testing) add custom_css param to theme class add custom_css param to theme class Mar 6, 2026
@hannahblair hannahblair marked this pull request as ready for review March 18, 2026 16:42
Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

LGTM @hannahblair ! Nice

@hannahblair hannahblair merged commit b51dc75 into main Mar 18, 2026
25 of 30 checks passed
@hannahblair hannahblair deleted the theme-custom-css branch March 18, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve documentation for building themes Allow embedding CSS into themes Allow pinning themes

3 participants