Sphinx Design

0.7.0 · active · verified Thu Apr 09

Sphinx Design is a Sphinx extension that provides a rich set of directives and roles for creating modern, responsive, and visually appealing web components within your documentation. It offers features like cards, grids, dropdowns, tabs, and icon support. The library is actively maintained with frequent updates, often aligning with new Sphinx and Python releases, ensuring compatibility and introducing new design capabilities.

Warnings

Install

Imports

Quickstart

To quickly enable `sphinx-design`, add `'sphinx_design'` to your `extensions` list in `conf.py`. After that, you can use its directives and roles (like `dropdown`, `card`, `grid`, `sd-icon`) directly in your reStructuredText or MyST Markdown files. The example demonstrates generating a `conf.py` and provides commented guidance for using directives in content files.

import os

def create_minimal_conf_py():
    conf_content = '''
project = 'My Design Docs'
copyright = '2023, Author'
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinx_design'
]
html_theme = 'furo'
'''
    with open('conf.py', 'w') as f:
        f.write(conf_content)

    # In a real scenario, you'd then create an index.rst or index.md like this:
    # with open('index.rst', 'w') as f:
    #     f.write('''
    # My Design Docs
    # ==============
    #
    # .. dropdown:: Click Me!
    #    :color: primary
    #
    #    This is a dropdown content block.
    #
    # .. card:: Feature Card
    #    :shadow: lg
    #    :text-align: center
    #
    #    A simple card to highlight information.
    #
    #    :::{link-button} https://example.com
    #    Visit Example
    #    :::
    # ''')

    print("Generated conf.py with sphinx_design extension enabled.")
    print("To use directives, add them to your .rst or .md files (e.g., dropdown, card, grid).")

if __name__ == '__main__':
    create_minimal_conf_py()

view raw JSON →