Skip to main content

Datasette plugin that keeps table headers visible while scrolling

Project description

datasette-sticky-table-headers

Keep Datasette table headers visible while scrolling.

This plugin is especially useful when exploring wide or unfamiliar datasets: column names stay in view while you scroll down table listings, database table previews, and SQL query results.

If you know this feature from spreadsheets, it is similar to "freeze top row" or "freeze header row": column names remain visible while you scroll through long or wide tables.

Installation

Install the plugin in the same environment as Datasette:

datasette install datasette-sticky-table-headers

For local development from this checkout:

pip install -e . --no-build-isolation

Usage

Run Datasette as normal. The plugin is enabled automatically:

datasette data.db

It injects a small script on Datasette table, database, and SQL query pages. That script adds CSS targeting thead header cells in Datasette result tables, so the header row sticks to the top of the browser viewport while the page scrolls.

.rows-and-columns thead th {
  position: sticky;
  top: 0;
}

The plugin also makes Datasette's table wrappers use normal page scrolling rather than a separate vertical scroll box, which lets sticky headers pin to the browser viewport.

Screenshots

Datasette table page with sticky headers visible while scrolling

The screenshot shows a Datasette table page scrolled down with the column headers still visible at the top of the page.

Compatibility and limitations

Tested with Datasette 0.65.2. The plugin uses Datasette's extra_body_script hook and standard Datasette table markup, so it should also work with nearby Datasette versions that render result tables with thead elements and the rows-and-columns class.

The CSS intentionally targets only thead cells. It does not use a tr:first-child fallback, because that can accidentally make the first data row sticky on result tables without a header section.

The header background is white. Datasette themes or custom CSS with non-white table backgrounds may need a small override.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datasette_sticky_table_headers-0.1.0.tar.gz (282.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file datasette_sticky_table_headers-0.1.0.tar.gz.

File metadata

File hashes

Hashes for datasette_sticky_table_headers-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1c898fe02a6e6fa30c91f441b663459ac91dee2fb87a5a664f7e3e300873521e
MD5 2ad9b94ab386e4c44e0b4c7b0c7ae435
BLAKE2b-256 3fbbff8fbfa9a14bfdf51c4f2785f62fb46707672f393ec85b05489f9a561708

See more details on using hashes here.

File details

Details for the file datasette_sticky_table_headers-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_sticky_table_headers-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d082e6ce633e38762bd07c40abd03e9439db782d4f7c6b6fa5852ac8f65db35
MD5 d773e0c8a3acddf475210c46b776a4ad
BLAKE2b-256 a6c8a7e2ed3e9872e7122e87ff36a4262f1bd14b2df52982557b75f017229e23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page