Skip to content

Conversation

@BoDonkey
Copy link
Contributor

Summary

Summarize the changes briefly, including which issue/ticket this resolves. If it closes an existing Github issue, include "Closes #[issue number]"
This PR adds new documentation for global and per-widget styles. It also adds reference documentation for the styles module. Closes PRO-8902, PRO-8403, and PRO-8992.

What are the specific steps to test this change?

For example:

  1. Run the website and log in as an admin
  2. Open a piece manager modal and select several pieces
  3. Click the "Archive" button on the top left of the manager and confirm that it should proceed
  4. Check that all pieces have been archived properly

What kind of change does this PR introduce?

(Check at least one)

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

@BoDonkey BoDonkey requested a review from boutell January 19, 2026 14:06
Copy link
Member

@boutell boutell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, some notes but nothing huge I think

text: 'Styling',
collapsed: true,
items: [
{ text: 'Global Styling', link: 'guide/global-styling.md' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global Styles / Widget Styles seems better, I don't think it makes sense to have two variations on the word, just makes it harder to find later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@@ -0,0 +1,1098 @@
# Global Styles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Styles" here (which I think is correct), file should be renamed to match

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.


## Configuration

Global styles are configured in a project-level `modules/@apostrophecms/styles/index.js` using a styles cascade that works much like the schema fields cascade. You define fields with types, labels, and properties—but instead of creating form inputs for content, these fields create controls for CSS properties.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use emdash, spaces around the emdash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed


#### `unit`

Append units to numeric values from `range` or `box` fields.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not supported for integer or float fields? If it's not then it's not...

Copy link
Contributor Author

@BoDonkey BoDonkey Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are only recommending range, I'm not going to change this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the integer and float fields. They are working so I updated this and added those fields in.


// URL function
valueTemplate: 'url(%VALUE%)'
// Result: url(image.jpg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to picture a scenario where this second example would actually work out, but offhand I can't think of one. Maybe a select field with /modules image URLs? Or just skip it, not asking you to add more work here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed that example, but also updated the section for named object fields.

### Performance considerations

- Widget styles are generated for each instance, so they add to page size
- For styles that should apply to all instances of a widget type, use regular CSS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use global styles or regular CSS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

- For styles that should apply to all instances of a widget type, use regular CSS
- Reserve widget styles for per-instance customization that content creators need

## When to use widget styles vs. global styles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole section is great 🔥

```

::: warning
Widget modules do not support the `group` property in their `styles` configuration. Attempting to use grouping with widget styles will cause an error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good note


### `serverRendered`

When set to `true`, all CSS rendering (including preview during editing) goes through your custom `getStylesheet` method. This is required when implementing custom CSS generation logic.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is available for global styles only. For performance reasons it is not available for widget-specific styles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified.


The module automatically injects styles into every page:

- **For guests:** `<link>` tag pointing to cached stylesheet endpoint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guests are logged-in users with a specific role. I suggest "for the public" or "for logged-out visitors."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@BoDonkey BoDonkey requested a review from boutell January 20, 2026 18:58
collapsed: true,
items: [
{ text: 'Global Styling', link: 'guide/global-styling.md' },
{ text: 'Global Styling', link: 'guide/global-styles.md' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global Styles should be the title too, I don't see any reason to potentially confuse a developer on this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumb oversight. Thanks.


**Every field needs:**
- `type` (or `preset`) - The control type: `color`, `range`, `string`, `select`, `box`, or a preset name
- `type` (or `preset`) - The control type: `color`, `range`, `integr`, `float`, `string`, `select`, `box`, or a preset name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

integr -> integer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

- **Design Editors**: Grant both `edit` and `editStyles` permissions (can edit everything)

::: warning
You must add `editPermission` to **every style field individually**. This includes fields within presets. The property cannot be set at the parent level and cascade down.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per Miro we need to update this, how about:

You must add editPermission to every style field individually. In the case of presets, you may set editPermission once for each use of the preset and it will be applied to every field generated by that use of the preset.

| **Delivery** | Cached stylesheet + inline | Inline per widget |
| **Interface** | Dedicated admin UI | Widget editor modal |
| **Selectors** | Required | Optional (for nested elements) |
| **Grouping** | Supports nested groups | Not supported |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This additional note is still needed:

| **Overrides** | Supports custom render method | Not supported |

### `serverRendered`

When set to `true`, all CSS rendering (including preview during editing) goes through your custom `getStylesheet` method. This is required when implementing custom CSS generation logic.
**This option is only available for global styles.** Widget styles are always rendered server-side for performance reasons.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, we render them on the front end when editing, which is one of the reasons for this policy.

This would be better language:

"Widget styles are always rendered by our standardized logic for performance reasons."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@BoDonkey BoDonkey requested a review from boutell January 23, 2026 11:08
@BoDonkey BoDonkey merged commit 41d6c36 into main Jan 23, 2026
@BoDonkey BoDonkey deleted the pro-8902-add-styles branch January 23, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants