1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-04 11:13:15 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/howtos/faq/csFAQ_how_can_i_use_custom_field.tid
Mario Pietsch 19085a1277 Add data attributes to ViewTemplate (#3209)
* change 3 set-widgets to 1 var-widget call. Add data-tags and userClass.

* add new documentation and change the existing one accordingly.
2018-04-24 22:08:20 +01:00

30 lines
734 B
Plaintext

created: 201804111739
modified: 201804111739
title: Q: How can I use a custom field to style a tiddler?
tags: [[Custom Styles FAQ]]
''Consider the following usecase:'' <<.from-version "5.1.16">>
There is a field named: `rank`, which can hold different values eg: `species`.
''Answer:''
The idea is now: We dynamically create the stylesheet. The style-sheet can look like this:
"""
title: `myStyles`
tags: `$:/tags/Stylesheet`
"""
```
<$list filter="[rank[species]]">
[data-tiddler-title^="<$view field=title/>"] .tc-tiddler-body {
column-count: 2;
}
</$list>
```
This creates a CSS rule for every tiddler-title, that has a field `rank` and value `species`.
[[Learn more about possible attributes!|Attribute Selectors]]