Skip to content
Norn
Menu

norn-simple-table

A native table that scrolls sideways inside its own box when it is wider than the page, so the page never does. A column keeps a readable width instead of being crushed, so a narrow screen scrolls the table, and a shadow at an edge says there is more that way. Pass the <table> in the default slot, with a <caption> when it can have one. Cells and code in them wrap between words, never mid-word. While the box scrolls, as it does on a narrow screen, its script makes it a tab stop named by the caption, so a keyboard can scroll it. scrollTables in @allons-y/webc-patterns/markdown writes the same markup for Markdown tables. Row rules take --norn-ui-border-color, and the scroll shadows are drawn against the page surface, --norn-surface-base. The header row has no fill.

<norn-simple-table> a container, from @allons-y/webc-patterns

Examples

Color scheme
Width

Open on its own

Source
<norn-simple-table>
	<table>
		<caption>Options</caption>
		<thead>
			<tr><th scope="col">Option</th><th scope="col">Type</th><th scope="col">Default</th><th scope="col">Description</th></tr>
		</thead>
		<tbody>
			<tr><td><code>outputDirectory</code></td><td><code>string</code></td><td><code>"_site"</code></td><td>Where the build writes its pages.</td></tr>
			<tr><td><code>pathPrefix</code></td><td><code>string</code></td><td><code>"/"</code></td><td>A path every URL starts with, for a site in a subfolder.</td></tr>
			<tr><td><code>dropEmptyBundleTags</code></td><td><code>boolean</code></td><td><code>true</code></td><td>Removes a link or script whose bundle came out empty.</td></tr>
		</tbody>
	</table>
</norn-simple-table>
Color scheme
Width

Open on its own

Source
<norn-simple-table @striped @numeric="2 3">
	<template slot="note" webc:nokeep>Sizes are before compression.</template>
	<table>
		<caption>Table 1. Bundle sizes</caption>
		<thead>
			<tr><th scope="col">Package</th><th scope="col">Files</th><th scope="col">Kilobytes</th></tr>
		</thead>
		<tbody>
			<tr><td>Patterns</td><td>42</td><td>118.4</td></tr>
			<tr><td>Code sample</td><td>6</td><td>9.1</td></tr>
			<tr><td>OSS site</td><td>12</td><td>31.0</td></tr>
		</tbody>
	</table>
</norn-simple-table>
Color scheme
Width

Open on its own

Source
<div style="display: grid; gap: 1.5rem">
	<div style="display: grid; gap: 0.5rem">
		<p><code>striped = true</code></p>
		<div>
			<norn-simple-table @striped>
				<table>
					<caption>Options</caption>
					<thead>
						<tr><th scope="col">Option</th><th scope="col">Type</th><th scope="col">Default</th><th scope="col">Description</th></tr>
					</thead>
					<tbody>
						<tr><td><code>outputDirectory</code></td><td><code>string</code></td><td><code>"_site"</code></td><td>Where the build writes its pages.</td></tr>
						<tr><td><code>pathPrefix</code></td><td><code>string</code></td><td><code>"/"</code></td><td>A path every URL starts with, for a site in a subfolder.</td></tr>
						<tr><td><code>dropEmptyBundleTags</code></td><td><code>boolean</code></td><td><code>true</code></td><td>Removes a link or script whose bundle came out empty.</td></tr>
					</tbody>
				</table>
			</norn-simple-table>
		</div>
	</div>
	<div style="display: grid; gap: 0.5rem">
		<p><code>striped = false</code></p>
		<div>
			<norn-simple-table>
				<table>
					<caption>Options</caption>
					<thead>
						<tr><th scope="col">Option</th><th scope="col">Type</th><th scope="col">Default</th><th scope="col">Description</th></tr>
					</thead>
					<tbody>
						<tr><td><code>outputDirectory</code></td><td><code>string</code></td><td><code>"_site"</code></td><td>Where the build writes its pages.</td></tr>
						<tr><td><code>pathPrefix</code></td><td><code>string</code></td><td><code>"/"</code></td><td>A path every URL starts with, for a site in a subfolder.</td></tr>
						<tr><td><code>dropEmptyBundleTags</code></td><td><code>boolean</code></td><td><code>true</code></td><td>Removes a link or script whose bundle came out empty.</td></tr>
					</tbody>
				</table>
			</norn-simple-table>
		</div>
	</div>
</div>

Props

Write them with the @ prefix, and :@ for an expression.

NameTypeDescription
@striped boolean Tint every even body row with the raised surface, for a long table read across.
@numeric string The columns that hold numbers, by position from 1 to 8, separated by spaces, such as "2 3". They align at the end, with figures of one width.

Slots

NameDescription
default The table.
note A short note under the table, such as its source, in muted text. Phrasing content only: it renders in a paragraph.
label The region's name while it scrolls, as one element, hidden. Falls back to the caption, then the column headings, so the name is always in the page's language.

Tokens

The global tokens from tokens.json the component reads. Set one in a project's tokens.css to change it everywhere.

Type a value to try it in every example above. Reset puts the default back.

Token Type Default Override
--norn-ui-accentThe brand color, shared by every component. <color> #2346d4
--norn-ui-border-colorHairline color. <color> light-dark(#d3d8e2, #2d323e)
--norn-surface-basePage surface. Light and dark values. <color> light-dark(#ffffff, #101216)
--norn-surface-raisedRaised surface. <color> light-dark(hsl(40, 14%, 96%), #242932)
--norn-text-baseText color. <color> light-dark(#16181d, #eceef3)
--norn-text-mutedSecondary text color. <color> light-dark(#4b5160, #a4abba)
--norn-font-size-sSmall text: captions, code, navigation, and notes. <length> 0.875rem
--norn-space-xsExtra small spacing step. <length> 0.5rem
--norn-space-sSmall spacing step. <length> 0.75rem