Template:Sticky header/doc

From Chew Inclusive Terminology Glossary
Revision as of 12:48, 17 October 2023 by wikipedia>Timeshifter ("It only works with sortable tables." Moved to top so I am less likely to forget it again. :)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Lua error in Module:TNT at line 159: Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:I18n/Uses TemplateStyles.tab.

This adds a floating, sticky header to a table in desktop view, but not on cell phones. It only works with sortable tables.

It has been tested, and works, in these browsers: Firefox, Edge, Chrome, Opera. Header borders are missing in Firefox. For more info see: Help:Table#Tables with sticky headers

It works with simple one-line headers, and with complex, multi-line, multi-row headers that use colspan and rowspan in the headers.

See list of articles transcluding {{sticky header}}. See transclusion count.

Usage

Note: See sandbox with examples.

{{sticky header}} just above the table wikitext.

class=sticky-header to the top line of the table wikitext along with class=sortable. For example:

<syntaxhighlight lang=wikitext>

</syntaxhighlight>

With sticky template

Special cases

Note: See sandbox with examples.

Sometimes a single-row sticky header is required due to subsection table header rows within the table. Note placement of class=sticky below. Scroll down well into the table to see that the headers before subsections of the table do not stick. Those subsection headers should not stick since they change as you scroll down the table.

Wiki source excerpt: <syntaxhighlight lang=wikitext highlight=1,4>

COVID-19 vaccines authorized for emergency use or approved for full use

</syntaxhighlight>

Go down to a section farther down in the example sandbox for a more complex table with multi-row headers, and table subsections. A different solution was required.

Problems and solutions

See: Template talk:Sticky header.

It works with {{static row numbers}}. But it does not work with this subtemplate: {{static row numbers table}} (go there to see what to replace it with). It breaks this subtemplate: {{static row numbers arrows}}. The separate sort row disappears. Use {{sort row}} instead.