V3.2 Enhancement Guide
Framework 3.2 lets an existing plugin follow themes, dark mode, and device modes everywhere: in markup, in charts, in icons, and in text and image outlines. This guide walks through each enhancement you can adopt (theme readiness, adaptive charts, adaptive icons, JS paint, the border step rail, and legible overlaid text and images), one at a time and in any order.
1. Make Your Plugin Theme-Ready
A theme restyles the whole screen by remapping which tokens paint each surface. Your plugin does not load themes itself; it renders inside a screen that may carry one. A plugin is theme-ready when everything it draws goes through framework classes and tokens.
- Style with framework utilities (
bg--,text--,border--) and elements (label,value,title). Themes remap all of them. - Avoid hardcoded hex colors and inline styles; a theme cannot remap paint it does not own.
- Test with the Style selector in the docs screen picker. It applies a theme to every example on the page.
To theme a screen you control, include the theme stylesheet and add the theme class. Note that screen--dark-mode has no effect on a themed screen; a theme is a complete color statement. See
Themes
Themes
Opt-in stylesheets that re-theme screens while preserving device-capability rendering
Themes are standalone stylesheets that re-point semantic channels, component slots, and utility tokens at different palette tokens. A themed screen still renders through its device mode: dither patterns on 1-bit, palette images on limited color, solids on full color.
.
<link rel="stylesheet" href="plugins.css">
<link rel="stylesheet" href="themes/black-and-yellow-theme.css">
<div class="screen screen--theme-black-and-yellow">...</div>
2. Migrate Charts to TRMNLCharts
Charts with hardcoded colors stay frozen while the rest of the screen adapts. The plugin runtime bundles TRMNLCharts, a Highcharts adapter that resolves series fills, grid lines, and text styles from the live screen.
- Build your chart inside
TRMNLCharts.watch()so it rebuilds when the device, scale, mode, dark mode, or theme changes. - Start from
TRMNLCharts.options()merged under your own settings. - Color each series with
TRMNLCharts.series(i, n)instead of a literal color. - Convert numeric chart dimensions with
TRMNLPaint.px().
var el = document.getElementById("my-chart");
TRMNLCharts.watch(el, function () {
var px = function (value) { return TRMNLPaint.px(value, { el: el }); };
Highcharts.chart(el, TRMNLCharts.merge(TRMNLCharts.options({ el: el }), {
chart: { height: px(260) },
plotOptions: { series: { lineWidth: px(4) } },
series: [
{ data: incoming, color: TRMNLCharts.series(0, 2, { el: el }) },
{ data: outgoing, color: TRMNLCharts.series(1, 2, { el: el }) }
]
}));
// Paint legend markers tagged data-chart-series="i" from the same ramp.
TRMNLCharts.applySwatches({ el: el });
});
Full examples for line, multi-series, and bar charts are on the Chart Chart Visualize data optimized for 1-bit rendering With careful, minimal styling choices, TRMNL can display a variety of numerical or time centric content as charts and graphs. page.
3. Mark Monochrome Icons Adaptive
Add image--adaptive to monochrome silhouette icons. The framework flattens the icon to its alpha shape and repaints it with the screen's icon paint, following Raw/Preview, bit depth, dark mode, and the active theme.
<!-- Monochrome silhouette icons (shape on a transparent background) -->
<img class="image--adaptive" src="path to icon">
- Silhouettes only: never use it on photos or multi-color logos. Use Image Stroke Image Stroke Legible images when displayed on shaded backgrounds Outline a vector or transparent raster image so it stays legible on a shaded background. Set the stroke width and color with the image stroke utilities. to keep those legible instead.
- Icons must be same-origin or served from a CORS-enabled host, or the framework leaves them unpainted. See Image Image Optimize images using dithering techniques for 1-bit rendering Place images on a screen and control their size, object fit, and inversion. On 1-bit displays, dithering arranges black and white pixels so an image still reads as shades of gray. .
4. Resolve Paint from JavaScript
For custom JS-drawn visuals beyond Highcharts (canvas, SVG, other libraries), resolve framework paint with TRMNLPaint. It reads the live cascade, so bit depth, dark mode, themes, and limited palettes are already applied.
// A background token: solid color on 4-bit+, dither tile on 1-bit.
var fill = TRMNLPaint.bg("gray-40", { el: "my-visual" });
// The effective one-color value of a text utility for SVG or canvas text.
var ink = TRMNLPaint.textColor("default", { el: "my-visual" });
// Rebuild whenever the screen device, scale, mode, dark mode, or theme changes.
TRMNLPaint.watch("my-visual", function () { draw(); });
The full resolver and painter surface is documented on Paint API Paint API TRMNLPaint: read the live CSS cascade from JavaScript to resolve framework colors and tile patterns TRMNLPaint is the framework's public JavaScript paint API. It reads the live CSS cascade (bit depth, dark mode, theme, limited palette, and tiles all resolved) and hands back a canonical Fill, so token mappings are never duplicated in JavaScript. Charts are just one consumer; any plugin can resolve framework colors from JS for any purpose. .
5. Move Borders to the Step Rail
Replace the numbered border levels with shade-step selectors (the numbered classes still render, but they are deprecated). Steps use the same 10 to 75 scale as the background utility, and themes repaint the whole rail. The rail now renders as generated gradients instead of PNG tiles, so a bordered screen fetches no border images.
<!-- Before: numbered levels (deprecated) -->
<div class="item border--h-5">...</div>
<!-- After: shade steps, plus semantic black/white rails -->
<div class="item border--h-45">...</div>
<div class="item border--h-black">...</div>
See Border Border Apply border patterns that create the illusion of different border intensities Draw a horizontal or vertical rule on any element with the border--h and border--v utilities, named on the same 10 to 75 shade scale as backgrounds. On 1-bit displays a step renders as a dither pattern of black and white pixels, so a rule can read as gray. 4-bit and full-color screens draw all 14 steps; the other rails pair them onto seven levels. for the full step scale and the themed rendering behavior.
6. Keep Overlaid Text and Images Legible
Text and images placed over a shaded or patterned surface can lose contrast. The Text Stroke and Image Stroke utilities outline them, and both were rebuilt to follow themes, dark mode, and bit depth like the rest of the screen.
- Add
text-stroketo framework text over a busy background, and size it withtext-stroke--smallthroughtext-stroke--xlarge. The stroke renders as drop-shadow rings, so it stays behind the glyph and behind background-clipped pattern fills in every browser. - Add
image-stroketo a transparent or vector image for the same effect, with the matching--smallthrough--xlargesizes. - Leave the color off to stroke with the default contrast ink, or set one with a color variant (
text-stroke--black,image-stroke--white, or any palette token). Color variants resolve through the theme chain, so themed and dark-mode screens recolor the outline to match.
<!-- Framework text over a shaded background -->
<span class="value text-stroke text-stroke--medium">64%</span>
<!-- Transparent or vector image over a pattern -->
<img class="image-stroke image-stroke--large" src="path to icon">
Full size and color scales are on the Text Stroke Text Stroke Legible text when displayed on shaded backgrounds Outline text so it stays legible on a shaded background. Set the stroke width and color with the text stroke utilities. and Image Stroke Image Stroke Legible images when displayed on shaded backgrounds Outline a vector or transparent raster image so it stays legible on a shaded background. Set the stroke width and color with the image stroke utilities. pages.