Restyle the designer

Give your theme's CSS to the designer with one filter, or reach its parts with ::part() from any stylesheet. Every custom property with its default, the stable class names, and two built-in choices: total only, and no colour picker for one colour.

Updated , for PrintBlob 1.8.6.

The designer draws itself in a shadow root, so no rule of your theme reaches it by accident: not a theme’s button, and not a page builder’s CSS either. You restyle it on purpose, in three ways. They work together, and the first two are all most shops need.

  1. Custom properties set on the designer’s element change its colours, corners, type and room. See Theme integration for the short version.
  2. Parts, named areas of the designer, are reached from any stylesheet of your page with ::part().
  3. A stylesheet given to the designer on one PHP filter reaches everything inside it, classes included.

The element you style is the designer’s host: .wp-block-printblob-designer on WordPress and [data-printblob-designer] in PrintBlob for Shopify’s block. Where this page writes the first, write the second on Shopify. Its first frame, which the server draws before the script runs, takes the same CSS as the running designer, so nothing moves when it starts.

This page is for PrintBlob 1.8.2 or later. The parts, the Price breakdown setting and leaving out the Colour section for one colour came with it; before it, a stylesheet given on the filter styled the first frame only.

Custom properties

Set these on .wp-block-printblob-designer, from your theme’s CSS or theme.json. Each has the default shown, which is also what the designer uses when your theme’s palette has no such colour.

Property Default Used for
--printblob-ink var(--wp--preset--color--ink, #1a1d22) Text and the main buttons
--printblob-heather var(--wp--preset--color--heather, #5f6670) Secondary text
--printblob-seam var(--wp--preset--color--seam, #e2e4e0) Lines and field borders
--printblob-cotton var(--wp--preset--color--cotton, #f6f7f5) The stage behind the product photo
--printblob-cobalt var(--wp--preset--color--cobalt, #2645d6) Add to cart and focus outlines
--printblob-cobalt-deep var(--wp--preset--color--cobalt-deep, #1b33a6) The ring around Add to cart under the pointer
--printblob-surface var(--wp--preset--color--white, #fff) Panels and fields
--printblob-on-ink var(--wp--preset--color--white, #fff) Text on ink-coloured buttons
--printblob-on-cobalt #fff Text on the accent: set it dark for a light accent
--printblob-fill color-mix(in srgb, var(--printblob-ink) 8%, var(--printblob-surface)) Fills of the sides switch and other quiet controls
--printblob-muted color-mix(in srgb, var(--printblob-ink) 80%, var(--printblob-surface)) Quieter labels
--printblob-radius var(--wp--custom--printblob--radius, 6px) Corner radius of buttons
--printblob-field-radius min(var(--printblob-radius), 14px) Corner radius of fields, so pill-shaped buttons keep moderate fields
--printblob-rem max(1rem, 16px) The designer’s own rem: the page’s, never under 16 px
--printblob-title-font inherit The product name’s typeface
--printblob-title-weight bold The product name’s weight
--printblob-stage-room 12rem The window height the stage leaves to what stands above and below it
--printblob-stage-share 62.5% The stage’s share of the designer’s width beside the controls
--printblob-colors-accent var(--wp--preset--color--cobalt, currentColor) The Colours block’s outline and name (set it on the block’s own element)

Each swatch carries its own colour in --printblob-swatch, set by the designer; read it in a rule for a swatch, for example background: var(--printblob-swatch), and do not set it.

.wp-block-printblob-designer {
	--printblob-ink: #14213d;
	--printblob-cobalt: #0a7d5a;
	--printblob-cobalt-deep: #075c42;
	--printblob-radius: 999px;
	--printblob-title-font: Georgia, serif;
}

A property set on a part reaches what is inside it: .wp-block-printblob-designer::part(panel) { --printblob-radius: 0; } squares the controls in the panel and leaves the stage as it was.

The parts

A part is an area of the designer that a page names. From your own stylesheet, with no filter and no JavaScript, reach it as .wp-block-printblob-designer::part(<name>). Parts exist in the first frame and in the running designer alike.

Part What it is
stage-column The stage with the side tabs above it and the hint below
views The bar above the stage that holds the side tabs and the views’ buttons
sides The side tabs
side One side’s tab. It also has current while it is the side shown
stage The product picture the print is placed on
hint The line under the stage about the print area
panel Everything beside the stage: the title, the price and the controls
title The product’s name
price The product’s price
print-section The “Your print” section
tools Upload image, Add text and the tools plugins add
workbench The designs on the side and the controls of the one chosen
colour-section The Colour section. It is left out for a product with one colour
colours The colour swatches
size-section The Size section
sizes The size buttons
size One size button. It also has pressed while it is chosen
option-section A section of another choice a plugin adds, such as a material
extension A section a plugin adds to the panel or to the buy block
options That section’s buttons
option One of them, with pressed while it is chosen
buy The block that holds the quantity, the breakdown and Add to cart
quantity The quantity field
breakdown The price breakdown
breakdown-line One line of the breakdown that is not the total: the product, a side’s print
total The total’s line
add-to-cart The Add to cart button
messages What the designer says after Add to cart

current and pressed are states, not parts of their own: they sit beside side, size and option, so ::part(side current) is the side tab that is shown. A ::part() can be followed by a state pseudo-class (:hover, :focus-visible, :disabled) or a pseudo-element (::before), and nothing else: not a class, an attribute, a structural pseudo-class such as :first-child or a child selector, which is what the states are for.

.wp-block-printblob-designer::part(title) {
	letter-spacing: 0.02em;
	text-transform: uppercase;
}
.wp-block-printblob-designer::part(add-to-cart) {
	border-radius: 0;
}
.wp-block-printblob-designer::part(size pressed) {
	background: var(--printblob-ink);
	color: var(--printblob-on-ink);
}

A page’s ::part() rule wins over the designer’s own, whatever its specificity. A rule should never move something on hover or focus: change a colour or draw a ring, so the designer does not shift under the pointer.

Give the designer a stylesheet

A rule for something a part does not name (an element inside a part), a class, a container query or a :has() needs a stylesheet inside the designer’s root. Give its file on the PHP filter printblob_designer_styles, from your theme or a plugin:

add_filter(
	'printblob_designer_styles',
	static function ( array $files ): array {
		$files[] = get_theme_file_path( 'assets/printblob-designer.css' );
		return $files;
	}
);

That one filter is enough. The designer’s first frame prints each file you give it, after the designer’s own, and the running designer adopts the same files when it starts: no JavaScript filter is needed, and the restyle holds before and after the designer starts. The filter takes the path of a readable .css file, which names no other file by a relative address (it is printed in the page, not loaded from its folder), and a file that is missing or would end its own style element is left out. It is told the designer’s configuration and the product, so a file can be given for some products only. The designer’s other hooks, for a plugin that adds a tool, a view or a section to it, are in Developer hooks.

If you have already registered the same file on the JavaScript filter printblob.designer.styles, as a CSSStyleSheet built from its contents, leave it: a sheet with the same rules as one the PHP filter gave is adopted once. A @font-face does not register from inside a shadow root: declare fonts in your page’s own CSS.

The designer is a size container named printblob-designer, so a stylesheet you give can answer to the designer’s own width, not the window’s:

@container printblob-designer (max-width: 720px) {
	.printblob-designer__panel {
		padding-inline: 1rem;
	}
}

The designer switches to its one-column layout at 720 px wide and shrinks its size buttons under 420 px. Write container queries in the stylesheet you give on the filter, which is inside the designer where its container is; a page’s ::part() rules answer to the window with @media.

The classes that stay

These class names are stable: a stylesheet given on the filter can rely on them. Other classes are the designer’s own and may change.

Class Where
printblob-designer__layout The grid of the stage column and the panel
printblob-designer__stage-column The stage with its tabs and hint
printblob-designer__views The bar above the stage
printblob-designer__sides The side tabs
printblob-designer__side One side’s tab
printblob-designer__stage The stage
printblob-designer__hint The hint under the stage
printblob-designer__panel The panel
printblob-designer__title The product’s name
printblob-designer__price The price
printblob-designer__section A section of the panel
printblob-designer__extension A section a plugin adds
printblob-designer__tools The tools
printblob-designer__workbench The designs on the side and their controls
printblob-designer__buy The quantity, breakdown and Add to cart
printblob-designer__messages The messages
printblob-designer__status The status line that says what is happening
printblob-sizes A row of size or option buttons
printblob-size A size or option button
printblob-swatches A row of swatches
printblob-swatch A swatch
printblob-field A labelled field
printblob-field--qty The quantity field
printblob-breakdown The price breakdown
printblob-breakdown__total The breakdown’s total line
printblob-button A button
printblob-button--primary The main button
printblob-note A note under the controls

Each class, and each part above, is checked against the designer as it is drawn, on WordPress and on Shopify, so a release that dropped one would fail its tests before it shipped.

Two choices the designer makes

Total only. Under WooCommerce › Settings › PrintBlob, Price breakdown is Every line (the default) or Total only. With Total only the designer lists the total alone: the product’s line, each side’s print and the line for the least the print costs are not drawn, in the first frame and in the running designer, so nothing moves. In PrintBlob for Shopify it is the same setting on the app’s Settings page. To hide the lines for one theme only, leave the setting alone and write .wp-block-printblob-designer::part(breakdown-line) { display: none; }.

One colour, no picker. A product with one colour has no Colour section: there is nothing to choose, so the designer does not ask. A product with two or more colours has it. The first frame and the running designer agree on it, so the page does not move when the designer starts.

A branded restyle, worked through

A shop wants three things: side tabs as outlines, with the current one filled; quantity, size and total on one row, above Add to cart; and the total alone. Set Price breakdown to Total only, then put this in your theme’s CSS. It is parts only, so it needs no filter: the first frame and the running designer both take it.

/* Outlined side tabs, the current one filled. */
.wp-block-printblob-designer::part(sides) {
	--printblob-surface: transparent;
}
.wp-block-printblob-designer::part(side) {
	border: 2px solid var(--printblob-ink);
	background: transparent;
	box-shadow: none;
	color: var(--printblob-ink);
}
.wp-block-printblob-designer::part(side current) {
	background: var(--printblob-ink);
	color: var(--printblob-on-ink);
}

/* One row for quantity, size and total, above Add to cart. */
.wp-block-printblob-designer::part(panel) {
	display: grid;
	grid-template-columns: 7rem minmax(0, 1fr) auto;
	gap: 1rem;
	align-items: end;
}
.wp-block-printblob-designer::part(title),
.wp-block-printblob-designer::part(price),
.wp-block-printblob-designer::part(print-section),
.wp-block-printblob-designer::part(colour-section),
.wp-block-printblob-designer::part(option-section),
.wp-block-printblob-designer::part(extension),
.wp-block-printblob-designer::part(add-to-cart),
.wp-block-printblob-designer::part(messages) {
	grid-column: 1 / -1;
}
.wp-block-printblob-designer::part(buy),
.wp-block-printblob-designer::part(breakdown) {
	display: contents;
}
.wp-block-printblob-designer::part(quantity) {
	order: 1;
	grid-column: 1;
}
.wp-block-printblob-designer::part(size-section) {
	order: 2;
	grid-column: 2;
	margin: 0;
}
.wp-block-printblob-designer::part(total) {
	order: 3;
	grid-column: 3;
	grid-template-columns: auto;
	margin: 0;
}
.wp-block-printblob-designer::part(add-to-cart) {
	order: 4;
}
.wp-block-printblob-designer::part(messages) {
	order: 5;
}

The tabs’ outlines and fill win over the designer’s own tab styles, in every state, because a page’s ::part() rule outranks a rule inside the designer. --printblob-surface: transparent on sides takes the white pill that glides between the tabs away, so the outlined tabs do not show it moving behind them. The row works because buy and breakdown are display: contents: the quantity, the size section and the total become items of the panel’s grid, each given its order and column, while every section that is not in the row spans the full width.

If you leave Price breakdown on Every line, add .wp-block-printblob-designer::part(breakdown-line) { display: none; } for the same result in this theme only.

On a narrow designer the row should stack again. A container query is written in a stylesheet given on the filter (above), where it can see the designer’s container:

@container printblob-designer (max-width: 480px) {
	.printblob-designer__panel {
		grid-template-columns: minmax(0, 1fr);
	}
	.printblob-field--qty,
	.printblob-designer__panel > .printblob-designer__section,
	.printblob-breakdown__total {
		grid-column: 1;
	}
}

If something does not apply

  • A rule of your page that names a class does nothing: the page’s CSS does not reach into the designer. Use a part, or give the stylesheet on the filter.
  • A rule for a part is ignored when it is followed by anything but a state pseudo-class or a pseudo-element: write ::part(size pressed), not ::part(size)[aria-pressed].
  • The designer’s controls look unstyled for a moment: a stylesheet printed by the filter shows with the first frame, so check that the file is readable and that the path is absolute.

See also The product page in your theme for where the designer shows, and Settings for the rest of the PrintBlob tab.