| This is the talk page for discussing Legend and anything related to its purposes and tasks. |
|
| Archives: 1Auto-archiving period: 3 months |
Protected edit request on 16 August 2025
[edit]This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
At WT:CHEMS#Can someone make this template Night Mode compatible?, it was requested that a feature be added so that the legend can match a table with colors that invert in dark mode. –LaundryPizza03 (dc̄) 06:23, 16 August 2025 (UTC)
- LaundryPizza03, this template is just making the small, colored squares, not the larger box. I think you're looking for Template:Legend table. It's not template-protected, but you're welcome to reach out if you run into issues, Rjjiii (talk) 07:13, 16 August 2025 (UTC)
- This edit will be needed for Legend table as well. –LaundryPizza03 (dc̄) 07:16, 16 August 2025 (UTC)
LaundryPizza03, will design tokens not be enough for dark mode in the other template? Try looking at the boxes below in light and dark mode.
When a color is specified, nothing changes in dark mode:
{{legend|black|"Black"}}- "Black"
When a design token is used, dark mode changes the color:
{{legend|var(--color-base, #000000)|"var(--color-base, #000000)"}}- "var(--color-base, #000000)"
There are a bunch of colors available that are pretty close to what that template is using in its legend, Rjjiii (talk) 07:25, 16 August 2025 (UTC)
- I need one that inverts by disabling "mw-no-invert", since most tables with color-coding lack this. –LaundryPizza03 (dc̄) 07:31, 16 August 2025 (UTC)
- @LaundryPizza03, would you mind implementing the changes in the sandbox and then doing another edit request? I feel confused by that last reply and so may be missing something. The "mw-no-invert" class prevents a table cell's background color from changing in dark mode, but I thought that was what you were seeking to do? If you just give a table cell
style="background:var(--color-base, #000000);"or whatever design token color you need, it will invert for dark mode. Rjjiii (talk) 07:38, 16 August 2025 (UTC)- That doesn't work on my browser. –LaundryPizza03 (dc̄) 07:48, 16 August 2025 (UTC)
- @LaundryPizza03, would you mind implementing the changes in the sandbox and then doing another edit request? I feel confused by that last reply and so may be missing something. The "mw-no-invert" class prevents a table cell's background color from changing in dark mode, but I thought that was what you were seeking to do? If you just give a table cell
Protected edit request on 18 August 2025
[edit]This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
Import a new "invert" feature from the template sandbox. –LaundryPizza03 (dc̄) 18:35, 18 August 2025 (UTC)
- This has been completed. GauchoDude (talk) 18:58, 18 August 2025 (UTC)
- @LaundryPizza03, this does not appear to change or invert anything using the built-in dark mode, just the older dark mode gadget. Is that the intended behavior? Rjjiii (talk) 03:26, 23 August 2025 (UTC)
- I can't reproduce this issue. You need to use the parameter
invertto use it. –LaundryPizza03 (dc̄) 03:29, 23 August 2025 (UTC) - @Rjjiii I don't know what is happening; it is meant to disable "mw-no-invert". Is there a different procedure for the built-in dark mode? –LaundryPizza03 (dc̄) 03:31, 23 August 2025 (UTC)
- @LaundryPizza03, can you try out the built-in dark mode? It's available to logged-out editors too, so if you just open a tab in private/incognito mode then it'll be available. I understand that the
|invert=parameter is necessary; it just doesn't change anything for me on the built-in dark mode, Rjjiii (talk) 03:36, 23 August 2025 (UTC)- @Rjjiii: I can verify this issue now. A look at Periodic table found that some colors are never inverted in the built-in dark mode. –LaundryPizza03 (dc̄) 03:38, 23 August 2025 (UTC)
- @Rjjiii: I implemented a test of the feature that inverts in the built-in dark mode at the sandbox, but it just changes everything to black/white and I don't know why. red. –LaundryPizza03 (dc̄) 03:53, 23 August 2025 (UTC)
- This edit makes everything black/white. The fallback color is only used when the CSS variable
--color-baseis unavailable. Rjjiii (talk) 04:05, 23 August 2025 (UTC)- I can't find any tokens in the list that inverts a given color. I've observed that unlike the dark-mode gadget, built-in dark mode does not invert table or font colors by default. Light red. –LaundryPizza03 (dc̄) 04:11, 23 August 2025 (UTC)
- It doesn't really invert anything. Those tokens are variables with a dark mode and light mode value. TemplateStyles can also define a light mode and dark mode value for a template. Rjjiii (talk) 04:15, 23 August 2025 (UTC)
- I guess I don't have to do anything for this template. –LaundryPizza03 (dc̄) 04:22, 23 August 2025 (UTC)
- It doesn't really invert anything. Those tokens are variables with a dark mode and light mode value. TemplateStyles can also define a light mode and dark mode value for a template. Rjjiii (talk) 04:15, 23 August 2025 (UTC)
- I can't find any tokens in the list that inverts a given color. I've observed that unlike the dark-mode gadget, built-in dark mode does not invert table or font colors by default. Light red. –LaundryPizza03 (dc̄) 04:11, 23 August 2025 (UTC)
- This edit makes everything black/white. The fallback color is only used when the CSS variable
- @LaundryPizza03, can you try out the built-in dark mode? It's available to logged-out editors too, so if you just open a tab in private/incognito mode then it'll be available. I understand that the
- I can't reproduce this issue. You need to use the parameter
- @LaundryPizza03, this does not appear to change or invert anything using the built-in dark mode, just the older dark mode gadget. Is that the intended behavior? Rjjiii (talk) 03:26, 23 August 2025 (UTC)
Template-protected edit request on 23 August 2025
[edit]This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
Can we change
| <span class="legend-text" style="{{#if:{{{alt|}}}|color:{{{1|}}};}}font-family: monospace, monospace;">{{If empty|{{{alt|}}}|{{{text|}}}| }}</span>| }}
to
| <span class="legend-text" style="{{#if:{{{alt|}}}|color:{{{1|}}};}}{{#ifeq:{{{no-monospace|}}}|yes||font-family: monospace, monospace;}}">{{If empty|{{{alt|}}}|{{{text|}}}| }}</span>| }}
This allows for an option no-monospace to be specified and if it is yes then it does not render the text in the legend as monospace. This is an issue largely with US auto racing articles, for example, 2025 NASCAR Craftsman Truck Series#Schedule, where just an "O" displays a lot like a 0 in monospace font, but I'm sure there's also other uses for it. If this is changed, ping me and I can update the documentation as well. I tested it in my sandbox and it worked fine. Casablanca 🪨(T) 01:36, 23 August 2025 (UTC)
|no-monospace=yesis confusing. How about|monospace=no, which is easier to parse? Also, please demonstrate an example of how this change would be useful by editing Template:Legend/testcases. – Jonesey95 (talk) 12:06, 24 September 2025 (UTC)- Jonesey95, Sounds good! I've made those changes as you've requested. Thank you for reviewing this. Casablanca 🪨(T) 23:04, 25 September 2025 (UTC)
Protected edit request on 11 February 2026
[edit]This edit request to Template:Legend and Template:Legend inline has been answered. Set the |answered= parameter to no to reactivate your request. |
As the edit request from 18 August 2025 pointed out, inverting does not currently work for built-in dark mode. The fix for this is rather simple, it is simply missing a skin-invert class for when the |invert= parameter is supplied; I have made this change in {{legend/sandbox}} and {{legend inline/sandbox}} already, and am requesting them to be implemented:
{{legend|green|Green|invert=y}}
{{legend/sandbox|green|Green|invert=y}}
| − | class="legend-color {{#if: | + | class="legend-color {{#if:{{{invert|}}}|skin-invert|mw-no-invert}}" |
{{legend inline|red|Red|invert=y}}
{{legend inline/sandbox|red|Red|invert=y}}
Red
Red
| − | class="legend-color | + | class="legend-color {{#if:{{{invert|}}}|skin-invert|mw-no-invert}}" |
Thanks! ~ oklopfer (💬) 17:03, 11 February 2026 (UTC)
Done phuzion (talk) 12:36, 12 February 2026 (UTC)
- It may be better and more future-proof to use
|class=here. That is typically what we do in infobox templates where images may need to have one or more classes applied. – Jonesey95 (talk) 04:02, 15 February 2026 (UTC)
- It may be better and more future-proof to use