Metadata-Version: 2.4
Name: datasette-sticky-table-headers
Version: 0.1.1
Summary: Datasette plugin that keeps table headers visible while scrolling
Author: Julius Welby
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/jwelby/datasette-sticky-table-headers
Project-URL: Issues, https://github.com/jwelby/datasette-sticky-table-headers/issues
Project-URL: Source, https://github.com/jwelby/datasette-sticky-table-headers
Keywords: datasette,datasette-plugin,sticky-headers,fixed-headers,frozen-headers,freeze-top-row,tables
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Datasette
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database :: Front-Ends
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: datasette
Dynamic: license-file

# 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:

```bash
datasette install datasette-sticky-table-headers
```

For local development from this checkout:

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

## Usage

Run Datasette as normal. The plugin is enabled automatically:

```bash
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.

```css
.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](https://raw.githubusercontent.com/jwelby/datasette-sticky-table-headers/main/docs/screenshot.png)

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.
