Skip to content
v0.5 isn't released yet: these pages follow the main branch. To try it, install the release candidate, v0.5.0-rc.1.
Style with Pico

Style with Pico

--css=pico: Pico CSS 2.1.1, a framework that styles plain HTML, so its components write few classes. No build step and no JavaScript.

The products list with Pico, light

The products list with Pico, dark

Before you start

A project made with anetos new blog --css=pico, or switched to it with go tool anetos css:use pico.

Steps

1. Know its files

FileHolds
public/static/pico.min.cssPico as released, with pico.LICENSE.txt (MIT)
public/static/app.cssWhat Pico has no style of: the header’s layout, badges, colored messages, the danger, ghost, small and full buttons
views/ui/*.templThe components: <article> for a card, <small> for a field’s message and hint, <a role="button"> for a link button
views/ui/classes.goThe classes of each variant and size (secondary; danger, ghost, small, full from app.css) and tone

The header’s links wrap on a small screen; there is no menu button. A form with its errors (Pico marks the control and colors its message):

The new-product form with its errors, Pico

The new-product form with its errors, Pico, dark

2. Change its colors

Pico’s colors are CSS variables. Set them in app.css, which comes after pico.min.css, with Pico’s own selectors (a plain :root loses to them):

/* illustrative */
:root:not([data-theme=dark]), [data-theme=light] {
	--pico-primary: #6d28d9;
	--pico-primary-background: #6d28d9;
	--pico-primary-underline: rgba(109, 40, 217, .5);
	--pico-primary-hover: #5b21b6;
	--pico-primary-hover-background: #5b21b6;
	--pico-primary-focus: rgba(109, 40, 217, .25);
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme]) {
		--pico-primary: #a78bfa;
		--pico-primary-background: #7c3aed;
		--pico-primary-underline: rgba(167, 139, 250, .5);
		--pico-primary-hover: #c4b5fd;
		--pico-primary-hover-background: #6d28d9;
		--pico-primary-focus: rgba(167, 139, 250, .375);
	}
}
[data-theme=dark] {
	--pico-primary: #a78bfa;
	--pico-primary-background: #7c3aed;
	--pico-primary-underline: rgba(167, 139, 250, .5);
	--pico-primary-hover: #c4b5fd;
	--pico-primary-hover-background: #6d28d9;
	--pico-primary-focus: rgba(167, 139, 250, .375);
}

Pico’s docs list the others: spacing, radius, font. Pico’s other color themes (pico.violet.min.css…) are other files of its release: to use one, put it in public/static/ and link it from ui.Head in views/ui/shell.templ instead.

3. Use more of Pico

Pico styles HTML by its elements and roles, so your own components can use them without classes: <div role="group"> for buttons side by side, <details class="dropdown"> for a menu without JavaScript, <article> with a <header> for a card, <progress>, <dialog>. Put them in components of views/ui (Style your app).

How it works

Dark mode is Pico’s: it follows the visitor’s system, or data-theme="dark" (or "light") on <html>. css:use pico with the in a project that has it brings a newer Pico when a newer anetos carries one (Style your app).

Common problems

SymptomCauseFix
A variable set on :root changes nothingPico sets it with a more specific selectorUse Pico’s selectors, as above
A link button doesn’t respond to the space barIt’s a link (<a role="button">), Pico’s way to style one: links follow on EnterUse a ui.Button in a form for actions

Next steps