Classes
Theme
dataclass
Theme configuration object.
Available in templates as `site.theme` for theme developers to access
…
Theme
dataclass Theme configuration object.
Available in templates assite.themefor theme developers to access
theme-related settings.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str |
Theme name (e.g., "default", "my-custom-theme") |
default_appearance |
str |
Default appearance mode ("light", "dark", "system") |
default_palette |
str |
Default color palette key (empty string for default) |
features |
list[str] |
List of enabled feature flags (e.g., ["navigation.toc", "content.code.copy"]) |
config |
dict[str, Any] | None |
Additional theme-specific configuration from [theme] section Feature Flags: Features are declarative toggles for theme behavior. Users enable/disable features via config rather than editing templates. |
Methods 3
has_feature
Check if a feature is enabled.
has_feature
def has_feature(self, feature: str) -> bool
Check if a feature is enabled.
Parameters 1
feature |
str |
Feature key (e.g., "navigation.toc", "content.code.copy") |
Returns
True if the feature is in the enabled features listbool
—
from_config
classmethod
Create Theme object from configuration dictionary.
Attempts to load theme.yaml…
from_config
classmethod def from_config(cls, config: dict[str, Any], root_path: Path | None = None) -> Theme
Create Theme object from configuration dictionary.
Attempts to load theme.yaml first, then falls back to config dict. This allows themes to define their configuration in theme.yaml while still supporting site-level overrides in bengal.toml.
Parameters 2
config |
dict[str, Any] |
Full site configuration dictionary |
root_path |
Path | None |
Optional root path for theme discovery |
Returns
Theme object with values from config or theme.yamlTheme
—
to_dict
Convert theme to dictionary for template access.
to_dict
def to_dict(self) -> dict[str, Any]
Convert theme to dictionary for template access.
Returns
Dictionary representation of themedict[str, Any]
—
Internal Methods 1
__post_init__
Validate theme configuration.
__post_init__
def __post_init__(self) -> None
Validate theme configuration.