Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Styles API

3,071 sites Security covered Drupal 8–11
View on drupal.org

This module provides a central repository for theme templates, allowing themes to register their templates in YAML files instead of code. This makes theme definitions more organized and accessible for other modules to interact with. It also allows for the addition of administrative elements like labels, icons, and descriptions to these theme definitions.

This module allows other modules or themes to register theme templates on a YAML file (replacing hook_theme()) and provide a repository for all themes registered.

This will give more order to theme definitions, taking them away form code.

But moreover in this way themes and modules could gather information of registered themes implementation.

For example a module could alter block form to add select field to forms, providing a UI to easily assign predefined templates for elements, blocks or regions.

Among standard hook_theme() settings, the definition will add Admin UI elements like labels, icons, categories, descriptions.

Declaring themes

Themes must be registered on a *.themes.yml file with the following format:

block__clean:
  label: Clean Wrapper
  type: block
  category: Block
  configuration:
    path: templates/clean
    base hook: block
    render element: elements

The id of the theme will name the template as in hook_theme().
Path is relative to the module or template, base path eill be added for proper rendering.

Basic functions

Style::stylePluginManager()->getDefinitions() will return all themes declared.

Projects using Styles API

We hope this module will be merged into core: Declare themes on YAML file as an alternative to hook_theme

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

1 tracked project depends on this one

Activity

Tracked releases
1
Tracked since
Jan 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
8.x-1.3 Stable 8–11 Jan 22, 2025