Template:Prettytable/Documentation: Difference between revisions

Template page
w:c:strategywiki>DrBob
(Added note about notwide)
w:c:strategywiki>Najzere
m (adding unsortable class)
Line 7: Line 7:
* '''notwide''': If a value is given (1, 0 or anything) it will make the table not stretch to fit the area it is contained in.
* '''notwide''': If a value is given (1, 0 or anything) it will make the table not stretch to fit the area it is contained in.
* '''sortable''': If a value is given, it allows columns to be sorted by clicking on the little icon within the header cell at the top of the column.
* '''sortable''': If a value is given, it allows columns to be sorted by clicking on the little icon within the header cell at the top of the column.
**To change individual columns to be unsortable (for instance for images), use the "unsortable" class on the header cell.
* '''text center''': If a value is given, text will be centre-aligned.
* '''text center''': If a value is given, text will be centre-aligned.
* '''float''': A side on which to float the table ("left" and "right" are the allowed values). Setting "float" automatically sets the "notwide" parameter too.
* '''float''': A side on which to float the table ("left" and "right" are the allowed values). Setting "float" automatically sets the "notwide" parameter too.
Line 58: Line 59:
===Full example===
===Full example===
<pre>{| {{prettytable|notwide=1|sortable=1|text center=1|style=font-size:0.8em}}
<pre>{| {{prettytable|notwide=1|sortable=1|text center=1|style=font-size:0.8em}}
! First column !! Second column !! Third column
!class="unsortable"| First column !! Second column !! Third column
|-
|-
| A || B || C
| A || B || C
Line 66: Line 67:


{| {{prettytable|notwide=1|sortable=1|text center=1|style=font-size:0.8em}}
{| {{prettytable|notwide=1|sortable=1|text center=1|style=font-size:0.8em}}
! First column !! Second column !! Third column
!class="unsortable"| First column !! Second column !! Third column
|-
|-
| A || B || C
| A || B || C

Revision as of 23:16, 2 March 2009

Template to put at the top of table declarations to standardise and prettify their appearance. By default it will make the table occupy all the page's width. If you want to turn it off, call the template as follows: {{prettytable|notwide=1}}. Additionally, you can mark the table as sortable (i.e. if it's a table of sortable values, such as {{yes}} or {{no}}), by using the "sortable" parameter: {{prettytable|sortable=1}}. Text can be centred in the table using {{prettytable|text center=1}}. Finally, extra styling can be added using the "style" parameter.

Using the "notwide" parameter is discouraged for normal situations: tables should be full-width, or left- or right-floated if that makes things look better.

Parameters

  • notwide: If a value is given (1, 0 or anything) it will make the table not stretch to fit the area it is contained in.
  • sortable: If a value is given, it allows columns to be sorted by clicking on the little icon within the header cell at the top of the column.
    • To change individual columns to be unsortable (for instance for images), use the "unsortable" class on the header cell.
  • text center: If a value is given, text will be centre-aligned.
  • float: A side on which to float the table ("left" and "right" are the allowed values). Setting "float" automatically sets the "notwide" parameter too.
  • style: Additional style values are allowed; usage is simply the CSS values not surrounded by quotes.
  • class: Additional CSS class names (separated by spaces) to apply to the table.

Example

Wide

{| {{prettytable}}
| Boo!
| Foo
| Bar
|-
| Test
| 2
| 3
|}
Boo! Foo Bar
Test 2 3

Not wide

{| {{prettytable|notwide=1}}
| Boo!
| Foo
| Bar
|-
| Test
| 2
| 3
|}
Boo! Foo Bar
Test 2 3

Full example

{| {{prettytable|notwide=1|sortable=1|text center=1|style=font-size:0.8em}}
!class="unsortable"| First column !! Second column !! Third column
|-
| A || B || C
|-
| 1 || 2 || 3
|}
First column Second column Third column
A B C
1 2 3