Template talk:Infobox nutritional value

Needs to be collapsible

[edit]

The template clearly has a useful function but it can take up a very large amount of screen space, and in particular it occupies a great length on the right hand side, making image, diagram and table placement difficult. It would be very helpful if the template could have a parameter to allow it to be collapsed where necessary. Chiswick Chap (talk) 08:10, 21 April 2017 (UTC)[reply]

Agree...is there any good workaround to hide/collapse it? —Hyperik talk 21:59, 4 August 2019 (UTC)[reply]
Infoboxes are not collasible. There are widgets that hide IBs (and they don't show on mobile) but you'd need an RFC to change how infoboxes display. Primefac (talk) 23:33, 4 August 2019 (UTC)[reply]
Popping in here to agree that this needs to be collapsible, since it takes up an enormous amount of space. Why specifically are they not collapsible? And, where could a request be made to suggest making this kind of change to infoboxes so they allow flexibility of use? Cheers —Kittycataclysm (talk) 23:26, 28 April 2024 (UTC)[reply]
The one potentially very long (19 lines) section is the amino acid section. I've made it foldable, though the formatting of the fold-title leaves something to be desired. The other potentially troublesome sections are the breakdown of sugars and fats, but they are nowhere as bad as the 19 AAs. Artoria2e5 🌉 10:00, 10 June 2025 (UTC)[reply]

Centre-aligned labels on mobile view appear haphazard

[edit]
Chia seeds, dried, raw
Nutritional value per 100 g (3.5 oz)
Energy486 kcal (2,030 kJ)
42.1 g
Dietary fiber34.4 g
30.7 g
Saturated3.3 g
Monounsaturated2.3 g
Polyunsaturated23.7 g
17.8 g
5.8 g
16.5 g
Vitamins and minerals
VitaminsQuantity
%DV
Vitamin A equiv.
6%
54 μg
Thiamine (B1)
52%
0.62 mg
Riboflavin (B2)
13%
0.17 mg
Niacin (B3)
55%
8.83 mg
Folate (B9)
12%
49 μg
Vitamin C
2%
1.6 mg
Vitamin E
3%
0.5 mg
MineralsQuantity
%DV
Calcium
49%
631 mg
Iron
43%
7.7 mg
Magnesium
80%
335 mg
Manganese
118%
2.72 mg
Phosphorus
69%
860 mg
Potassium
14%
407 mg
Zinc
42%
4.6 mg
Other constituentsQuantity
Water5.8 g

Percentages estimated using US recommendations for adults,[1] except for potassium, which is estimated based on expert recommendation from the National Academies.[2]

On my Android Chrome's Mobile view (but not Desktop view), header cells are centre-aligned, as in this table from chia seed..

As the left column is made of header cells, and the labels are whitespace-padded to fake indentation, they appear haphazardly aligned.

Can these cells be explicitly left-justified? cmɢʟeeτaʟκ 09:19, 24 September 2024 (UTC)[reply]

P.S. A remedy is to wrap the arguments of label# (where # is an integer) with

<div style="text-align:left;">

and

</div>

(or add text-align:left; to its style if it's already a div) e.g.

Before (see in Mobile view):
30.7 g
Saturated3.3 g
Monounsaturated2.3 g
Polyunsaturated23.7 g
17.8 g
5.8 g
After (see in Mobile view):
30.7 g
3.3 g
2.3 g
23.7 g
17.8 g
5.8 g

cmɢʟeeτaʟκ 14:15, 24 September 2024 (UTC)[reply]

This is because the relevant style (text alignment) isn't loaded on mobile. It should be Soon. Izno (talk) 15:20, 24 September 2024 (UTC)[reply]
And soon is defined more or less by the resolution of phab:T375538. Izno (talk) 17:31, 24 September 2024 (UTC)[reply]
Thanks for explaining, @Izno: I'll leave it as is and await a solution then. Cheers, cmɢʟeeτaʟκ 19:21, 25 September 2024 (UTC)[reply]

References

  1. ^ United States Food and Drug Administration (2024). "Daily Value on the Nutrition and Supplement Facts Labels". FDA. Archived from the original on 2024-03-27. Retrieved 2024-03-28.
  2. ^ "TABLE 4-7 Comparison of Potassium Adequate Intakes Established in This Report to Potassium Adequate Intakes Established in the 2005 DRI Report". p. 120. In: Stallings, Virginia A.; Harrison, Meghan; Oria, Maria, eds. (2019). "Potassium: Dietary Reference Intakes for Adequacy". Dietary Reference Intakes for Sodium and Potassium. pp. 101–124. doi:10.17226/25353. ISBN 978-0-309-48834-1. PMID 30844154. NCBI NBK545428.

Add an ID

[edit]

Let's add IDs to these boxes so that they could be linked from articles or from outside, e.g. Pea#nutritional_value.

There could be more than one box on a page, so the ID should include something unique (name, I assume).

This could work:

{{anchor|nutritional_value_{{{name}}}}}

<span class="anchor" id="nutritional_value_{{{name}}}"></span>

Jack who built the house (talk) 05:27, 11 June 2025 (UTC)[reply]

Done. Jack who built the house (talk) 06:03, 13 December 2025 (UTC)[reply]
This causes broken anchors when certain syntax is used, e.g. at Persimmon. I looked for a definitive list of what characters could be in anchor names and ids, but I was unable to find one with a quick WP search. I've seen it somewhere. – Jonesey95 (talk) 22:24, 13 December 2025 (UTC)[reply]
My bad! I expected the template to use {{anchorencode:}} or at least mw.html:attr as it does in other wikis. Turned out Module:Anchor just adds <span id="">...</span> as plain text, without any safety measures whatsoever! 😬 I've created a proposal to introduce encoding to Module:Anchor.
I've run a search to find the usages of the problematic characters to prevent such occasions going forward.
This code appears to handle them well:
<span id="nutritional_value_{{anchorencode: {{{name<includeonly>|{{PAGENAMEBASE}}</includeonly>}}} }}"></span>
The buggy version was:
{{anchor|nutritional_value_{{{name<includeonly>|{{PAGENAMEBASE}}</includeonly>}}}}}
What do you think? Jack who built the house (talk) 08:12, 14 December 2025 (UTC)[reply]

Refs and dates in the templates

[edit]

Why are refs built into the template? The problem is the dates in the ref(s) are formatted a certain way (2017-03-27). Not all articles use this format. The problem with this is that articles, especially FA/GAs, are supposed to have consistent formatting and not all articles use that date format. So if such an article uses March 27, 2017, it's inconsistent if said article also uses this template. MisawaSakura (talk) 02:57, 11 October 2025 (UTC)[reply]

source field

[edit]

source - sets the data source of the information used in the template.

What does it mean "sets"? Should a URL be included or a citation template? If the source is often USDA, can we come up with a field for USDA ID or something? Or at least provide a preferred format of USDA citations? Jack who built the house (talk) 03:47, 19 November 2025 (UTC)[reply]

Looking at the current usage:
—it looks like the more widespread format is to use the note field to link Food Data Central (e.g. see Pecan#Nutrition: "Link to Full USDA Database Information"). But there is not a word about this in the docs; the docs merely say this:

note - a convenient way to indicate serving sizes or edible parts, e.g., 1 banana is 100 to 150 g or other information.

Jack who built the house (talk) 03:52, 19 November 2025 (UTC)[reply]
But this:
|note            = [https://fdc.nal.usda.gov/food-details/170182/nutrients Link to Full USDA Database Information]
—is a bad format actually; if the URL format changes at USDA, we'd have to do a bot replace instead of changing the URL in one place. A preferred format could be something like usda_id = 170182, despite that this ID could also change in a flash, but that'd be a bit more stable. Jack who built the house (talk) 03:56, 19 November 2025 (UTC)[reply]