Template:IconText: Difference between revisions
Created page with "<includeonly>{{trim| {{#lvardef: icon | {{{1}}} }} {{#lvardef: link | {{{link|}}} }} {{#lvardef: text | {{{2}}} }} {{#lvardef: min-w | {{{w | {{{size | 40}}} }}} }} {{#lvardef: max-w | {{{w|}}} }} {{#lvardef: max-h | {{{h | {{{size | 40}}} }}} }} }}{{#if: {{{block|}}} | <span style="display: inline-flex; align-items: center; {{#if: {{{gap|}}} | gap: {{{gap}}}px; }}"> }}<span style=" display: inline-flex; align-items: center; justify-content: center; min-width: {{..." |
HiddenDragon (talk | contribs) mNo edit summary |
||
(15 intermediate revisions by 4 users not shown) | |||
Line 3: | Line 3: | ||
{{#lvardef: link | {{{link|}}} }} | {{#lvardef: link | {{{link|}}} }} | ||
{{#lvardef: text | {{{2}}} }} | {{#lvardef: text | {{{2}}} }} | ||
{{#lvardef: min-w | {{{w | {{{size | | {{#lvardef: min-w | {{#if: {{{w|}}} | {{{w}}} | {{#if: {{{size|}}} | {{{size}}} | 40 }} }} }} | ||
{{#lvardef: max-w | {{{w|}}} }} | {{#lvardef: max-w | {{{w|}}} }} | ||
{{#lvardef: max-h | {{{h | {{{size | | {{#lvardef: max-h | {{#if: {{{h|}}} | {{{h}}} | {{#if: {{{size|}}} | {{{size}}} | 40 }} }} }} | ||
}}{{#if: {{{block|}}} | }}{{#if: {{{block|}}} | ||
| <span style="display: inline-flex; align-items: center; {{#if: {{{gap|}}} | gap: {{{gap}}}px; }}"> | | <span class="bg3wiki-icontext-block" style="display: inline-flex; align-items: center; {{#if: {{{gap|}}} | gap: {{{gap}}}px; }}"> | ||
}}<span style=" | | {{#if:{{{nowrap|}}}|<span style="white-space: nowrap">}} | ||
}}<span class="bg3wiki-icontext-icon-wrapper" style=" | |||
display: inline-flex; | display: inline-flex; | ||
align-items: center; | align-items: center; | ||
Line 14: | Line 15: | ||
min-width: {{#lvar:min-w}}px; | min-width: {{#lvar:min-w}}px; | ||
height: {{#lvar:max-h}}px; | height: {{#lvar:max-h}}px; | ||
">{{icon | "><span class="bg3wiki-icontext-icon" style="vertical-align: middle;">{{icon | ||
| {{#lvar:icon}} | | {{#lvar:icon}} | ||
| link = {{#lvar:link}} | | link = {{#lvar:link}} | ||
Line 20: | Line 21: | ||
| w = {{#lvar:max-w}} | | w = {{#lvar:max-w}} | ||
| h = {{#lvar:max-h}} | | h = {{#lvar:max-h}} | ||
}}</span> <span>{{#if: {{#lvar:link}} | | class = {{{class|}}} | ||
}}</span></span> <span class="bg3wiki-icontext-text">{{#if: {{#lvar:link}} | |||
| [[{{#lvar:link}}|{{#lvar:text}}]] | | [[{{#lvar:link}}|{{#lvar:text}}]] | ||
| {{#lvar:text}} | | {{#lvar:text}} | ||
}}</span>{{#if: {{{block|}}} | }}</span>{{#if: {{{block|}}} | ||
| </span> | | </span> | ||
| {{#if: {{{nowrap|}}}|</span>}} | |||
}}</includeonly><noinclude>{{Documentation|content= | |||
Displays an icon with text. | |||
== Usage == | |||
The default size is {{code|x40px}} meaning the icon is scaled until the '''height''' is 40 px. It's usually important to limit the height since the icons are used inline, and a very high inline image makes for an unpleasant text layout. | The default size is {{code|x40px}} meaning the icon is scaled until the '''height''' is 40 px. It's usually important to limit the height since the icons are used inline, and a very high inline image makes for an unpleasant text layout. | ||
=== Icon Size === | |||
The width can be set via the {{code|w}} parameter. This could be useful if several elements are supposed to align vertically for design purposes, such as in the following table shown on our main page as of the writing of this documentation. This also uses the {{code|block}} and {{code|gap}} parameters. (View the source of this page for usage.) | |||
=== Blocks === | |||
Setting {{code|block}} to yes ensures that if the text part has to break into multiple lines, the second line doesn't flow under the icon and instead the text is constrained into a rectangular block. The {{code|gap}} parameter can only be provided if block is set to yes, and determines the gap (in px) between the icon and the aforementioned rectangular text block. | |||
== Examples == | |||
{{Template demo | |||
| style = table | |||
| caption 1 = Default | |||
| <nowiki>{{IconText | Flourish Icon.png | Flourish }}</nowiki> | |||
| caption 2 = With link | |||
| {{IconText | | | <nowiki>{{IconText | Flourish Icon.png | Custom Text | link = Flourish }}</nowiki> | ||
| | | caption 3 = Adjusting size | ||
| <nowiki>{{IconText | size = 25 | Flourish Icon.png | Flourish }}</nowiki> | |||
| {{IconText | | | caption 4 = With size and link | ||
| <nowiki>{{IconText | size = 25 | Flourish Icon.png | Custom Text | link = Flourish }}</nowiki> | |||
| caption 5 = Missing icon | |||
| | | <nowiki>{{IconText | Missing Icon 123.png | Flourish | size = 30 }}</nowiki> | ||
| | }} | ||
| {{IconText | | |||
| | |||
| {{IconText | | |||
| | |||
| {{IconText | | |||
[[Category:Icon | }} | ||
[[Category:Templates]] | |||
[[Category:Icon templates]] | |||
</noinclude> | </noinclude> |
Latest revision as of 12:23, 19 January 2025
Displays an icon with text.
Usage
The default size is x40px
meaning the icon is scaled until the height is 40 px. It's usually important to limit the height since the icons are used inline, and a very high inline image makes for an unpleasant text layout.
Icon Size
The width can be set via the w
parameter. This could be useful if several elements are supposed to align vertically for design purposes, such as in the following table shown on our main page as of the writing of this documentation. This also uses the block
and gap
parameters. (View the source of this page for usage.)
Blocks
Setting block
to yes ensures that if the text part has to break into multiple lines, the second line doesn't flow under the icon and instead the text is constrained into a rectangular block. The gap
parameter can only be provided if block is set to yes, and determines the gap (in px) between the icon and the aforementioned rectangular text block.
Examples
Example | Markup | Renders as |
---|---|---|
Default | {{IconText | Flourish Icon.png | Flourish }} | |
With link | {{IconText | Flourish Icon.png | Custom Text | link = Flourish }} | |
Adjusting size | {{IconText | size = 25 | Flourish Icon.png | Flourish }} | |
With size and link | {{IconText | size = 25 | Flourish Icon.png | Custom Text | link = Flourish }} | |
Missing icon | {{IconText | Missing Icon 123.png | Flourish | size = 30 }} |