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.
GalleryConfig(hidden=False, icon=None, theme=None, group=None, order=0, canvas_template=None, extra_context=dict(), param_defaults=dict(), 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. |
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
133 134 135 136 137 138 139 140 141 142 | |
get_variant(name)
Return the variant matching name, or None.
Source code in dj_design_system/gallery.py
169 170 171 172 173 174 | |
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)
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 built-in variants ("basic", "maximal") so they do not clutter the sidebar tree, and True for custom named variants. Explicitly set to True or False to override this default. |
from_dict(data, name=None)
classmethod
Create a Variant from a dictionary or mapping.
Source code in dj_design_system/gallery.py
58 59 60 61 62 63 64 | |
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
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |