Gallery Configuration API Reference
All gallery configuration classes live in dj_design_system.gallery. Use GalleryConfig and Variant to configure component metadata, navigation hierarchy, canvas rendering, and variations.
Gallery configuration and variant definitions for components.
DocVariantConfig(key, name, label, strategy=DocVariantStrategy.MINIMAL, show_in_docs=True, kwargs=dict(), param_factory=None, slot_factory=None)
dataclass
Normalized configuration for a standard documentation variant.
Attributes:
| Name | Type | Description |
|---|---|---|
key |
str
|
Identifier key in |
name |
str
|
Variant slug matched against |
label |
str
|
Heading label displayed in the Usage documentation section. |
strategy |
DocVariantStrategy
|
Built-in generation strategy used when the variant is not overridden in |
show_in_docs |
bool
|
Whether this variant is included in component documentation by default. |
kwargs |
dict[str, Any]
|
Optional static parameter overrides for custom global variants. |
param_factory |
Callable[..., Any] | None
|
Reserved hook for custom parameter value factory callables. |
slot_factory |
Callable[..., Any] | None
|
Reserved hook for custom slot content factory callables. |
GalleryConfig(hidden=False, icon=None, theme=None, group=None, order=0, canvas_template=None, extra_context=dict(), param_defaults=dict(), doc_variants=None, variants=list())
dataclass
Explicit configuration for a component within the design system gallery.
Attributes:
| Name | Type | Description |
|---|---|---|
hidden |
bool
|
If True, hides the component and its variants from gallery navigation and search. |
icon |
str | None
|
Custom icon name (e.g. |
theme |
str | None
|
Theme override for the component preview. |
group |
str | None
|
Grouping category for sidebar navigation. |
order |
int
|
Ordering priority integer for sidebar navigation. Lower numbers appear first. |
canvas_template |
str | None
|
HTML template string for wrapping previews. Operates in Smart Hybrid mode:
if |
extra_context |
dict[str, Any]
|
Context variables passed to preview templates. |
param_defaults |
dict[str, Any]
|
Mapping of param names to default values or callables. |
doc_variants |
Mapping[str, Any] | Sequence[Any] | None
|
Optional component-level documentation variant overrides (mapping or sequence)
layered on top of the global |
variants |
list[Variant]
|
List of named Variant instances. To construct from dictionary mappings,
use |
from_dict(data)
classmethod
Create a GalleryConfig from a dictionary or mapping.
Converts nested variant dictionaries or mappings into Variant instances.
Source code in dj_design_system/gallery.py
200 201 202 203 204 205 206 207 208 209 | |
get_doc_variants()
Return resolved documentation variant configurations for this component.
Source code in dj_design_system/gallery.py
242 243 244 245 246 247 248 249 250 251 252 | |
get_variant(name)
Return the variant matching name, or None.
Source code in dj_design_system/gallery.py
254 255 256 257 258 259 | |
Variant(name, label=None, description=None, kwargs=dict(), positional_args=tuple(), canvas_template=None, extra_context=dict(), icon=None, theme=None, show_in_nav=None, show_in_docs=None)
dataclass
A named component variation with preset arguments and preview configurations.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique identifier slug for this variant (e.g. |
label |
str | None
|
Human-readable display label in documentation and sidebar navigation. Defaults to title-cased name. |
description |
str | None
|
Optional markdown text describing when/how to use this variant. |
kwargs |
dict[str, Any]
|
Component keyword parameters passed to instantiation. Supports raw values,
|
positional_args |
tuple[Any, ...]
|
Positional argument values passed to the component tag. |
canvas_template |
str | None
|
Optional variant-level HTML layout override for previewing this variant. |
extra_context |
dict[str, Any]
|
Additional template context variables available during preview rendering. |
icon |
str | None
|
Optional icon name or SVG path for sidebar navigation. |
theme |
str | None
|
Optional theme override when previewing this variant. |
show_in_nav |
bool | None
|
Whether to display this variant as a child node in the gallery sidebar navigation.
When left as None, defaults to False for standard global documentation variants
(e.g. |
show_in_docs |
bool | None
|
Whether to render this variant as an example in the component documentation pane.
When left as None, defaults to True for enabled documentation variants
(e.g. |
from_dict(data, name=None)
classmethod
Create a Variant from a dictionary or mapping.
Source code in dj_design_system/gallery.py
121 122 123 124 125 126 127 | |
is_shown_in_docs(*, doc_variants=None)
Return whether this variant should be rendered in component documentation.
Source code in dj_design_system/gallery.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
is_shown_in_nav(*, doc_variants=None)
Return whether this variant should be rendered in sidebar navigation.
Source code in dj_design_system/gallery.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
load_gallery_config(source_dir, component_name)
Discover, import, and return the GalleryConfig for a component.
Checks for {name}_gallery.py, {name}.gallery.py, or gallery.py
within source_dir. If found, imports the module safely and extracts
the config (or {name}_config) object. If legacy basic_kwargs
or maximal_kwargs are present without a config, emits a
DeprecationWarning and synthesizes a fallback config.
Source code in dj_design_system/gallery.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |