How to change the color of Tw icons

41 views
Skip to first unread message

Juan Palomo

unread,
Jun 27, 2022, 12:35:59 PMJun 27
to TiddlyWiki
Hello everyone.

Is there any way to change the color of TW's system icons? The fact is that I would like to use some icons in a table that I am making instead of text, but I cannot change their original black color.
I have read that it can be done using CSS, but I would like to know if it can be done in the text of a tiddler in some other way.
The code that I have tried, and that has not worked for me, is the following: 

<{{$:/core/images/tip}} fill=yellow>

Cheers

Eric Shulman

unread,
Jun 27, 2022, 12:50:47 PMJun 27
to TiddlyWiki
This will do what you want:
```
@@fill:yellow;{{$:/core/images/tip}}@@
```

enjoy,
-e

Juan Palomo

unread,
Jun 27, 2022, 1:16:13 PMJun 27
to TiddlyWiki
Thank you very much Eric!!!

Juan Palomo

unread,
Jun 27, 2022, 5:12:46 PMJun 27
to TiddlyWiki
One more question. I have tried to modify the size of the icon since it is larger than I want and I cannot find the parameter to adjust it.
I have tried the following formula but it seems that it is not correct:

@@fill:blue; width:1em; height: 1em; {{$:/core/images/tip}}@@

Thanks a lot



PMario

unread,
Jun 28, 2022, 2:18:22 AMJun 28
to TiddlyWiki
On Monday, June 27, 2022 at 11:12:46 PM UTC+2 Juan Palomo wrote:
One more question. I have tried to modify the size of the icon since it is larger than I want and I cannot find the parameter to adjust it.
I have tried the following formula but it seems that it is not correct:

@@fill:blue; width:1em; height: 1em; {{$:/core/images/tip}}@@


That doesn't work that way, since the height and width are directly defined in the SVG element. You need to do the following.

Create 2 tiddlers eg: my-styles and my-macros

```
title: my-styles
tags: $:/tags/Stylesheet
code-body: yes

.my-icon svg {
    height: 1em;
}
```

```
title: my-macros
tags: $:/tags/Macro
code-body: yes

\define my-icon(title) <span class="my-icon"><$transclude tiddler=<<__title__>>/></span>
```

Call the macro with: `<<my-icon "$:/core/images/tip">>` ... That should do the trick.

The first tiddler my-styles defines a CSS stylesheet, that allows you to define the hight of the SVG element. Since it keeps the aspect ratio, it will scale properly if you only change hight.

The second tiddler defines a macro named: my-icon, that covers the SVG inside an HTML SPAN element and defines it's class="my-icon". Which allows the browser to assign the CSS stylesheet settings.

I did add a little ZIP file that contains a JSON file, which can be drag & drop imported into a wiki. You can test it with tiddlywiki.com. It should work there since I did mace the macros with it.

have fun!
mario


svg-macro-call.zip

TiddlyTweeter

unread,
Jun 28, 2022, 2:59:12 AMJun 28
to TiddlyWiki
PMario: "That doesn't work that way, since the height and width are directly defined in the SVG element. You need to do..."

That is a very nice solution to the SVG "change-dimensions" issue using a "class"!

TT

Xabriña

unread,
Jun 28, 2022, 10:37:18 AMJun 28
to TiddlyWiki
Hello Mario.

It is clear to me from the explanation you have given me that there is no choice but to use CSS and macros, and I appreciate you taking the trouble to leave me the files with the solution already prepared.

From what I see in the end, I have no choice but to either take the path that you have indicated, and that I was trying to avoid due to my programming limitations, or find a way to adjust the size of the icons that interest me and put them directly and then with the method that Eric told me to change the color to the one I need.

Thank you very much!!!

Reply all
Reply to author
Forward
0 new messages