You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many times where you want to populate a single page with many Sphinx Design items that all share the same configuration. For example, "I want a list of 10 cards, each of which has a specific margin, padding, outline, or CSS class".
In these cases, there is a lot of toil and boilerplate duplication when adding them, since you have to manually edit the options for each one. It would be helpful if there were a way to define the default configuration of each item once and then re-use it throughout the page.
Proposal
Make it possible to define the default configuration of Sphinx Design components on a per-page level (or at the site-level). There are two ways I could think of to do this:
However I don't know that this would be doable in rST...
Set page-level defaults with a directive. For example, perhaps there was a sd-default directive. Inside that directive you could define any arbitrary Sphinx Design objects. It would render them as normal, but would also then set the configuration of each object to be the default for any subsequent objects on the page. e.g.:
I think actually this would be more general, and actually easier, to implement this in myst-parser!
Obviously, this would only then be supported in Markdown/MyST-NB documents, but then well, people should use those 😄
Activity
[-]Per-page default configuration[/-][+]Per-page default configuration for components[/+]chrisjsewell commentedon Aug 22, 2022
I think actually this would be more general, and actually easier, to implement this in myst-parser!
Obviously, this would only then be supported in Markdown/MyST-NB documents, but then well, people should use those 😄
[-]Per-page default configuration for components[/-][+]Per-page default option values for directives[/+]chrisjsewell commentedon Jul 12, 2026
Thanks for this — it directly shaped what became the
sd_custom_directivesconfiguration in v0.6.0: you can define a directive once inconf.py(inheriting from e.g.grid-item-card) with your default margin/padding/class options and reuse it everywhere, which addresses the boilerplate concern here. Docs: https://sphinx-design.readthedocs.io/en/latest/get_started.html#creating-custom-directivesClosing as delivered; if a true per-page override mechanism is still wanted on top of that, happy to consider it in a fresh issue.