diff --git a/panel/template/base.py b/panel/template/base.py index 14f7250a7df..8d72d1a73ad 100644 --- a/panel/template/base.py +++ b/panel/template/base.py @@ -44,6 +44,7 @@ from ..theme.base import ( THEMES, DefaultTheme, Design, Theme, ) +from ..theme.native import Native from ..util import isurl from ..viewable import ( MimeRenderMixin, Renderable, ServableMixin, Viewable, @@ -119,6 +120,12 @@ def __init__( } self._render_items: dict[str, tuple[Renderable, list[str]]] = {} self._render_variables: dict[str, Any] = {} + if ( + 'design' not in params + and self.param.design.default in (None, Design, Native) + and config.design is not None + ): + params['design'] = config.design super().__init__(**{ p: v for p, v in params.items() if p not in _base_config.param or p == 'name' }) diff --git a/panel/tests/template/test_base.py b/panel/tests/template/test_base.py index a2435c94daa..4296459ea65 100644 --- a/panel/tests/template/test_base.py +++ b/panel/tests/template/test_base.py @@ -4,6 +4,7 @@ from panel.io.notifications import NotificationArea from panel.io.state import set_curdoc, state from panel.template import VanillaTemplate +from panel.theme import Material from panel.widgets import Button @@ -34,6 +35,13 @@ def test_notification_explicit(document): assert state.notifications is tmpl.notifications +def test_template_inherits_configured_design(): + with config.set(design=Material): + tmpl = VanillaTemplate() + + assert tmpl.design is Material + + def test_template_pass_config_params_constructor(document): custom_config = { 'raw_css': ['html { background-color: purple; }'],