Skip to content

Intergrate tiddlywiki palette colors and settings to custom CSS properties - #9333

Merged
Jermolene merged 27 commits into
TiddlyWiki:masterfrom
Leilei332:tiddlywiki-css-property
Feb 4, 2026
Merged

Jermolene merged 27 commits into
TiddlyWiki:masterfrom
Leilei332:tiddlywiki-css-property

Conversation

@Leilei332

@Leilei332 Leilei332 commented Oct 11, 2025 •

Copy link
Copy Markdown
Contributor

This PR adds a stylesheet to intergrate palette colors and theme settings to CSS custom properties

Compared to using wikitext syntax, using custom CSS properties has these benefits:

  • var() is more advanced, it supports fallback.
  • Theme creators can use vanilla CSS instead of mixing CSS and wikitext. This allows editors to highlight CSS properly and check errors.

TODO

  • Add palette color properties
  • Add tiddlywiki style settings properties
  • Update docs

@netlify

netlify Bot commented Oct 11, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for tiddlywiki-previews ready!

Name Link
🔨 Latest commit 64d4f53
🔍 Latest deploy log https://app.netlify.com/projects/tiddlywiki-previews/deploys/697ed98f3c825a0008cb347f
😎 Deploy Preview https://deploy-preview-9333--tiddlywiki-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown

Confirmed: Leilei332 has already signed the Contributor License Agreement (see contributing.md)

@Leilei332
Leilei332 marked this pull request as draft October 11, 2025 11:12
Comment thread core/stylesheets/custom-properties.tid Outdated
Comment thread core/stylesheets/custom-properties.tid Outdated
Comment thread core/stylesheets/custom-properties.tid Outdated
Comment thread editions/tw5.com/tiddlers/Core CSS Variables.tid Outdated
@pmario

pmario commented Nov 8, 2025

Copy link
Copy Markdown
Member

Hi @Leilei332 ... I just saw your latest changes and I do have some thoughts.

TW prefixes are there to make the live for users easier. IMO --tp-color-alert-background is way much to type. Even for the core. I think --tp_ for tiddlywiki palette or parameter is a good prefix.

IMO --tcc-something would mean tw custom color, so we can get rid of the -color-

Other tc-, tv-, tm-,... prefixes are designed to be used by the core. The t stands for tiddlywiki They stand out, that users can use the unprefixed version of the same variable name. eg: TW would use .tc-myStyle for a class name. So users can use .myStyle in their apps, without naming clashes.

IMO the same principle should be used for custom CSS properties.

If something should be used by the core it is prefixed. This does not mean, that it is not allowed to be changed by the user. It is only an opinionated default name, that should "go out of the users way"

IMO if we have custom CSS properties that are that long as this PR suggests, it will be a horror to use them in more complex CSS formulas. I think eg: var(--tp-color-external-link-foreground-visited) is a monster and I would hate to use it for complex CSS calculations.

IMO it should be --tcc-external-link-foreground-visiged, to make it somewhat shorter and keep the same name. A global search for "external-link-foreground-visited" will find it.

I personally would prefer --tcc-external-link-FG-visited and --tcc-external-link-BG-visited because FG and BG stand out more and are easier to spot. But I think @Jermolene will not be happy with that one.

@github-actions

github-actions Bot commented Nov 15, 2025 •

Copy link
Copy Markdown

📊 Build Size Comparison: empty.html

Branch Size
Base (master) 2448.0 KB
PR 2449.8 KB

Diff: ⬆️ Increase: +1.8 KB


✅ Change Note Status

All change notes are properly formatted and validated!

📝 $:/changenotes/5.4.0/#9333

Type: feature | Category: developer
Release: 5.4.0

Intergrate Tiddlywiki palette colors and settings to custom CSS properties

🔗 #9333

👥 Contributors: Leilei332


📖 Change Note Guidelines

Change notes help track and communicate changes effectively. See the full documentation for details.

change-category: developer
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9333
github-contributors: Leilei332

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm, Since there is a second documentation tiddler, which shows both variants, I think the release note can only show the new behaviour - Just a thought

@TiddlyWiki TiddlyWiki deleted a comment from github-actions Bot Nov 15, 2025
:root {
<$list filter="[[$:/palettes/Vanilla]indexes[]]">
--tpc-<<currentTiddler>>: <$transclude $variable="colour" $mode="inline" name=<<currentTiddler>>/>;
</$list>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the rendered output created with the following code looks a bit better, since it avoids the extra newlines.

:root {
<$list filter="[[$:/palettes/Vanilla]indexes[]]">
	--tpc-<<currentTiddler>>: <$transclude $variable="colour" $mode="inline" name=<<currentTiddler>>/>;</$list>

```css
/* New way to get a palette color without wikitext */
.tag {
background: var(--tp-color-tag-background);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO there is a typo --tpc. It should be --tpc-tag-background

}
```

See [[Writing stylesheets in vanilla CSS]] and [[Core CSS Variables]] for details. No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
See [[Writing stylesheets in vanilla CSS]] and [[Core CSS Variables]] for details.
See:
* [[Writing stylesheets in vanilla CSS]] and [[Core CSS Variables]] for details.
* https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/var

@Leilei332
Leilei332 marked this pull request as ready for review January 30, 2026 08:31
The previous example actually doesn't work at all
title: Core CSS Variables
type: text/vnd.tiddlywiki

<<.from-version 5.4.0>> Tiddlywiki CSS variable definitions starts with `--tp-*` and `--tpc-*`. They are mainly used to [[Write stylesheets in vanilla CSS|Writing stylesheets in vanilla CSS]]. These prefixes ''are reserved'' for Tiddlywiki, so it should not be used for user defined CSS variables. It is also not recommended to override these core CSS variables.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<<.from-version 5.4.0>> Tiddlywiki CSS variable definitions starts with `--tp-*` and `--tpc-*`. They are mainly used to [[Write stylesheets in vanilla CSS|Writing stylesheets in vanilla CSS]]. These prefixes ''are reserved'' for Tiddlywiki, so it should not be used for user defined CSS variables. It is also not recommended to override these core CSS variables.
<<.from-version 5.4.0>> Tiddlywiki CSS variable definitions starts with `--tp-*` and `--tpc-*`. They are mainly used to [[Write stylesheets in vanilla CSS|Writing stylesheets in vanilla CSS]].
* These prefixes ''are reserved'' for Tiddlywiki, so it should not be used for user defined CSS variables.
* It is also ''not recommended'' to override these core CSS variables.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There also should be some information what --tp and --tpc means. This info even can be duplicated in several places if needed.

<<.from-version 5.4.0>> Before v5.4.0, theme developers have to mix wikitext syntax with CSS syntax when writing stylesheets to intergrate Tiddlywiki color palettes and theme settings. With the introduction of [[Core CSS Variables]] in v5.4.0, theme developers can intergrate most Tiddlywiki palettes with vanilla CSS.

! Getting Tiddlywiki palette colors
Tiddlywiki's custom properties for colors are prefixed `--tpc-`. Before v5.4.0, theme developers have to use the following wikitext to get a color value of a palette:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Tiddlywiki's custom properties for colors are prefixed `--tpc-`. Before v5.4.0, theme developers have to use the following wikitext to get a color value of a palette:
Tiddlywiki's custom properties for colors are prefixed `--tpc-` (tpc = ''t''w ''p''alette ''c''olour). Before v5.4.0, theme developers have to use the following wikitext to get a color value of a palette:


<<.from-version 5.4.0>> Tiddlywiki CSS variable definitions starts with `--tp-*` and `--tpc-*`. They are mainly used to [[Write stylesheets in vanilla CSS|Writing stylesheets in vanilla CSS]]. These prefixes ''are reserved'' for Tiddlywiki, so it should not be used for user defined CSS variables. It is also not recommended to override these core CSS variables.

Core CSS variables are defined in [[$:/core/stylesheets/custom-properties]].

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The tiddler $:/core/stylesheets/custom-properties is not human readable.

Is it possible to use code-body: yes and still use the tiddler properly?

If not IMO linking to it does not really make sense, so the link may be removed.

@Leilei332 Leilei332 mentioned this pull request Feb 1, 2026
}
```

While using CSS variables in media quert definitions doesn't work at all:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO typo: media query instead of quert

@saqimtiaz saqimtiaz moved this to Ready in Planning for v5.4.0 Feb 4, 2026
@Jermolene
Jermolene merged commit b236373 into TiddlyWiki:master Feb 4, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in Planning for v5.4.0 Feb 4, 2026
@Jermolene

Copy link
Copy Markdown
Member

Thanks @Leilei332

@pmario

pmario commented Feb 4, 2026

Copy link
Copy Markdown
Member

@Leilei332 ... Even if this PR is merged, please have a look at my latest comments. There is a typo in the docs. ... And there seems to be a title-clash. Please check that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants