RoleWarden documentation

Design guide

Everything the panel looks like comes from tokens: CSS custom properties read by every component. A theme is nothing more than a set of values for them. This page uses the panel's own stylesheet, so the samples and the values below are always the ones the module ships.

Show |

Three levels, one rule

  1. Primitives (--p-blue-650, --p-graphite-25…): the raw colours. No component ever reads them.
  2. Semantic tokens (--surface, --ink, --accent, --text-md, --size-control…): a role, not a value. Every component reads only these.
  3. Component tokens: only where a component needs an exception, and always derived from a semantic token, never from a primitive.

The rule that keeps the panel coherent: no raw value in markup or component CSS, no arbitrary colour in a utility class, no spacing outside the scale. If a component cannot find the token it needs, a token is missing: add it to the scale, do not invent an exception. The only plain values are the widths of individual table columns and the geometry of icons, which are layout rather than theme.

How a theme is chosen

The <html> element carries data-rw-theme="console|clarity|contrast" (set from the Appearance screen, for everyone) and, when a user picked one in the top bar, data-rw-mode="light|dark"; without it the panel follows the operating system. Each theme defines its light and dark colours side by side as --l-* and --d-*, and one block picks the pair for the current mode.

Colour tokens

Values of the semantic colours in the theme and mode selected above, with the primitive each one points to. Text pairs meet WCAG AA (4.5:1) in all six combinations.

TokenRoleValue

Type, spacing and shape

IBM Plex Sans for the interface, IBM Plex Serif for page and section titles (Contrast sets titles in bold Sans), IBM Plex Mono only for permission identifiers such as users.delete. Figures are tabular. Families are not customisable in v1.0; themes change sizes and weights.

TokenUseValue

Components

Each component exists once, with its variants and states. Class names are the ones to use in a view.

Buttons .rw-btn

Fields .rw-field, .rw-input, .rw-select, .rw-check

Error: Field errors sit under their control, never in a toast.

Labels .rw-role, .rw-status

EditorAuthor ActiveInactive

Toast .rw-toast

Saved Changes saved.

Error: You cannot remove the last super admin.

Table .rw-t-users and ledger rows

UsernameRolesStatus
01Dana WhitfieldAdminActive
02Marco LeoneEditorInactive

Rules, not boxes: rows are separated by --rule, sections by --rule-strong. No cards, no zebra stripes. Every table keeps a left gutter (--gutter) for row numbers. Green (--granted) and red (--denied) mean granted and denied or destructive, never decoration. Every control has a visible focus ring (--focus, --focus-width).

Customising without touching the module

The Appearance screen changes the starting theme, the background, text and accent colours for light and dark, the corner radius and the density, with a live preview and a warning for any text colour under WCAG AA. It saves writable/rolewarden/theme.json; an application that keeps app/Config/RoleWarden/theme.json under version control wins over it. Neither file belongs to the module, so updating the module keeps the theme.

A fourth theme

Add a stylesheet to your application, declare it and the theme in app/Config/RoleWarden.php (a class extending RoleWarden\Config\RoleWarden), and the Appearance screen offers it next to the other three:

// app/Config/RoleWarden.php
class RoleWarden extends \RoleWarden\Config\RoleWarden
{
    public array $extraThemes = ['ocean' => 'Ocean'];
    public ?string $themeStylesheet = 'https://example.test/css/rolewarden-ocean.css';
}

/* public/css/rolewarden-ocean.css: map every semantic token, light and dark */
:root[data-rw-theme="ocean"] {
  --l-surface: #f7fafb; --l-ink: #0f1d24; --l-accent: #0b6e8a; /* ...every --l-* ... */
  --d-surface: #0c171c; --d-ink: #e8f2f5; --d-accent: #6cc3dc; /* ...every --d-* ... */
  --radius-md: 6px; --size-row: 44px; /* shape tokens you want to change */
}

Start from the table above: copy every colour token for both modes and change the values, then check each text colour against its background (4.5:1 for text, 3:1 for control borders). Leave out a token and the panel falls back to Console's value for it.

A component of your own

Put its CSS in the same stylesheet and build it only from semantic tokens: background var(--surface-raised), text var(--ink), border var(--rule-width) solid var(--rule-strong), height var(--size-control), radius var(--radius-md), spacing var(--space-*). Give it a focus state with outline: var(--focus-width) solid var(--focus). It then follows every theme, mode and customisation automatically.