Drupal 9 Components Library: The next theme system

JohnAlbin

For every version of Drupal I can remember, if a module wanted to display content, it had to provide the default HTML and CSS for it. This paradigm has served us well for years, but its time to radically improve the re-usability of our HTML and CSS by implementing a core components library.

Here's a rough idea of what we could do in Drupal 9:

  • Core would define the default component library.
  • The library would contain a collection of components (chunks of HTML, CSS, and JS). An individual component would be similar to today's theme hooks.
  • Each component would be documented so it can automatically be aggregated into a style guide.
  • If module authors want their modules to present data, they would peruse the component library style guide to discover the best component for their data.
  • To display data, a module would return a component object with its data inserted. (Nested components are supported.)
  • A contrib module could add additional components to the library if it can't find a core component to use.
  • A theme would create a fork of the default component library with some components overridden.
  • A "component transformer" would take a component object and convert it into another component object with the same data. Themes or modules could provide a component transformer.

What do you think?

Session Track

Core Conversations

Experience Level

Advanced

Drupal Version

When & Where

Time: 
Thursday, 14 May, 2015 - 13:00 to 14:00
Room: 
518 - Trellon