This project is not covered by Drupal’s security advisory policy.

Adds the Cordwainer Elements web component library to your site as ready-to-use Drupal Single Directory Components (SDCs). If you've ever wanted polished buttons, form fields, dialogs, navigation, layout and dozens of other interface pieces without writing them from scratch, this module gives you a full set you can place in a template, a block, Layout Builder or Drupal Canvas right away.

A "web component" is a small, self-contained piece of interface — say, a button or a date picker — built once and reusable in any HTML page, regardless of what framework (or no framework) built the rest of the site. Cordwainer Elements is a large, actively maintained library of these, and this module is the bridge that lets Drupal's component system see and use each one as a native SDC, complete with a themeable properties form.

Features

This module packages all 85 Cordwainer Elements components as individual SDCs, named after their tags (cordwainer_elements:cw-button, cordwainer_elements:cw-card, …). Each one exposes its attributes and CSS custom properties as editable props, and its named slots as SDC slots, so site builders can configure a component through Drupal's normal UI instead of hand-writing markup or JavaScript. The set covers most of what a typical site or design system needs:

  • Layout — cw-section, cw-stack, cw-grid, cw-divider, cw-split-panel
  • Form controls — cw-button, cw-checkbox, cw-radio, cw-radio-group, cw-select, cw-input, cw-textarea, cw-switch, cw-range, cw-combobox, cw-color-picker, cw-date-picker, cw-time-picker, and more
  • Navigation — cw-header, cw-footer, cw-logo, cw-primary-navigation, cw-secondary-navigation, cw-breadcrumb, cw-menu, cw-tab-group, cw-pagination, cw-stepper, cw-social-link
  • Overlays and popovers — cw-dialog, cw-drawer, cw-dropdown, cw-popover, cw-popup, cw-tooltip
  • Feedback and status — cw-alert, cw-badge, cw-progress-bar, cw-progress-ring, cw-spinner, cw-skeleton, cw-tag
  • Data display — cw-card, cw-data-table, cw-accordion, cw-details, cw-tree, cw-avatar, cw-avatar-group, cw-rating, cw-relative-time, cw-format-date, cw-format-number, cw-format-bytes
  • Media — cw-picture, cw-video-embed, cw-carousel, cw-image-comparer, cw-animated-image, cw-qr-code, cw-icon (with the full built-in icon set), cw-icon-button

A rich text component (cordwainer_elements:text) is included too, for free-form formatted text in Drupal Canvas, where the library's own components can't hold it.

Use this module when you want a consistent, accessible, themeable component library across your whole site without maintaining that library's markup, styles and behavior by hand — and without locking yourself into a JavaScript framework, since the underlying elements work anywhere HTML works.

Post-Installation

There is no configuration form to visit. Once you enable the module:

  • Every component appears wherever Drupal lists available components — the Canvas component picker, Layout Builder, and {{ include('cordwainer_elements:cw-button', { … }) }} calls from your own Twig templates.
  • Selecting a component in the UI shows a properties form generated from its attributes and CSS custom properties, so you can configure and theme it without touching code.
  • The element JavaScript, CSS and icons are vendored inside this module (no CDN calls at runtime) and attached automatically the moment a component is placed on a page — there's nothing to enable manually in a library or text format.
  • Web Component Runtime takes care of the rest: one <script type="importmap"> per page for the library's shared dependencies, such as Lit (Canvas pages and AJAX responses included), elements hidden until they're defined instead of flashing unstyled, and the light or dark theme switched on <html> before first paint, following the visitor's color scheme or <html data-color-scheme="dark"> when a theme pins it.

Additional Requirements

  • Drupal 11 or 12.
  • Web Component Runtime 1.1 or later. Composer installs it with this module, and enabling this module enables it. A site updating from an earlier release gets it installed by drush updatedb.

No API key or CDN access is needed. Because the underlying components are standard web components, visitors need a reasonably modern, evergreen browser (one that supports Custom Elements v1, ES modules and import maps); no support is provided for legacy browsers.

  • Drupal Canvas is not required, but if it's installed, these components can be composed visually on the canvas the same way any other SDC can, and Web Component Runtime handles their import map there.
  • UI Patterns pairs well with these components, giving site builders additional ways to expose and combine SDC props in the UI.

Similar projects

This module is generated output rather than a hand-maintained integration — it's produced from the library's Custom Elements Manifest by the Custom Elements Manifest to SDC Generator module. Where other component-library integrations on drupal.org are written and updated by hand for a specific set of elements, this module (and any other module produced the same way) stays in sync with its upstream library by regenerating from that library's manifest, rather than by manual porting.

Supporting this Module

This module has no dedicated funding page. If you'd like to support the component library it packages, see the Cordwainer Elements project itself. For issues specific to this Drupal integration, please use this project's issue queue on drupal.org.

Community Documentation

  • cordwainer.dev — full component documentation, live demos and theming guides for every element this module packages.
  • @cordwainer/cw-elements on npm — the underlying package this module vendors, including release notes and version history.
  • Web Component Runtime — how the import map, element hiding and color scheme switching work, for anyone building on these components.
  • Custom Elements Manifest to SDC Generator — the tool used to generate this module; useful if you want to see how it was built, regenerate it against a newer version of the library, or generate SDCs from a different web component library.

Project information

Releases