LukeDev
LukeDev

Reputation: 541

How to use custom CSS on a default Sphinx theme?

I'm creating documentation in Python with the Sphinx default theme agogo.

I would like to use the topic directive to put a box around important information but agogo's CSS doesn't have a border in it's default CSS. I have the CSS to create the border created, but how to I include/override the old version of agogo's topic to use my version instead.

I want to be able to generate the docs without changing the CSS manually every time. I researched a bit about using custom CSS with Sphinx but nothing seems to mention overriding an existing class.

Upvotes: 3

Views: 1677

Answers (1)

mzjn
mzjn

Reputation: 50947

Here we (ago)go:

  1. Create a file called custom.css in the _static subdirectory of the Sphinx project.

  2. In custom.css, add @import 'agogo.css'; and your own custom CSS code.

  3. Add html_style = 'custom.css' to conf.py (documentation).

Upvotes: 6

Related Questions