Wagtail’s user interface is built with:
Here are the available commands:
make lint
will run all linting, make lint-server
lints templates, and make lint-client
lints JS/CSS.make format
will run all formatting and fixing of linting issues. There is also make format-server
and make format-client
.Have a look at our Makefile
tasks and package.json
scripts if you prefer more granular options.
We use djhtml for formatting and Curlylint for linting.
data-
attributes for JavaScript behaviour.id
first, then class
, then any data-
or other attributes with Stimulus data-controller
first.We use Prettier for formatting and Stylelint for linting.
rems
for font-size
, because they offer absolute control over text. Additionally, unit-less line-height
is preferred because it does not inherit a percentage value of its parent element, but instead is based on a multiplier of the font-size
.w-
prefix for all styles intended to be reusable by Wagtail site implementers.We use Prettier for formatting and ESLint for linting.
(ui_guidelines_stimulus)=
Wagtail uses Stimulus as a lightweight framework to attach interactive behaviour to DOM elements via data-
attributes.
Stimulus is a lightweight framework that allows developers to create interactive UI elements in a simple way. It makes it easy to do small-scale reactivity via changes to data attributes and does not require developers to 'init' things everywhere, unlike JQuery. It also provides an alternative to using inline script tag usage and window globals which reduces complexity in the codebase.
Stimulus is our preferred library for simple client-side interactivity. It’s a good fit when:
Wagtail’s admin interface also leverages jQuery for similar scenarios. This is considered legacy and will eventually be removed. For new features, carefully consider whether existing jQuery code should be reused, or whether a rebuild with Stimulus is more appropriate.
First think of how to name the controller. Keep it concise, one or two words ideally. Then,
client/src/controllers
folder, along with its tests (see [](testing)) and Storybook stories.connect
, initialize
).disconnect
lifecycle method.microtick
) so will require a await Promise or similar to check for the changes in JSDom.this.identifier
if adjusting attributes. This way the controller can be used easily with a changed identifier or extended by other classes in the future.This is an area of active improvement for Wagtail, with ongoing discussions.
trimmed
attribute on blocktranslate
tags to prevent unnecessary whitespace from being added to the translation strings.We use inline SVG elements for Wagtail’s icons, for performance and so icons can be styled with CSS. View [](icons) for information on how icons are set up for Wagtail users.
Icons are SVG files in the Wagtail admin template folder.
When adding or updating an icon,
id
attribute with a prefix of icon-
and the icon name matching the file name. Keep the icon as named from its source if possible.<!--! Icon license -->
. For Font Awesome, we want: <!--! [icon name] ([icon style]): Font Awesome [version] -->
. For example, <!--! triangle-exclamation (solid): Font Awesome Pro 6.4.0 -->
.register_icons
hook, in alphabetical order.wagtail_icons_table.txt
.