https://github.com/zachleat/table-saw
A small web component for responsive <table> elements.
https://github.com/zachleat/table-saw
web-components
Last synced: about 1 year ago
JSON representation
A small web component for responsive <table> elements.
- Host: GitHub
- URL: https://github.com/zachleat/table-saw
- Owner: zachleat
- License: mit
- Created: 2023-09-28T18:17:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-29T16:21:58.000Z (about 2 years ago)
- Last Synced: 2025-03-28T13:09:40.413Z (about 1 year ago)
- Topics: web-components
- Language: HTML
- Homepage: https://zachleat.github.io/table-saw/demo.html
- Size: 49.8 KB
- Stars: 320
- Watchers: 3
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `table-saw`
A small structural-only zero-dependency Web Component for responsive `` elements. Heavily inspired by [Filament Group’s Tablesaw Stack jQuery plugin](https://github.com/filamentgroup/tablesaw).
## [Demo](https://zachleat.github.io/table-saw/demo.html)
## Examples
```html
```
* Use `breakpoint` attribute to set the breakpoint (default:`(max-width: 39.9375em)`).
* Use `type="container"` attribute to use container queries instead of viewport-based media queries (default: `type="media"`).
* Use `ratio` attribute to override the small viewport column ratio (default: `1/2`).
* Use `zero-padding` attribute to remove small viewport padding on table cells.
* Use `text-align` attribute to force column text alignment at small viewport.
## Installation
You have a few options (choose one of these):
1. Install via [npm](https://www.npmjs.com/package/@zachleat/table-saw): `npm install @zachleat/table-saw`
1. [Download the source manually from GitHub](https://github.com/zachleat/table-saw/tags) into your project.
1. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)
### Usage
Make sure you include the `` in your project (choose one of these):
```html
<!-- Host yourself -->
<script type="module" src="table-saw.js">
```
```html
```
```html
```
## Features
* Supports one or many `` child elements.
* Works with viewport media queries or container queries.
* Uses CSS grid for small viewport alignment.
* Falls back to regular table before or without JavaScript.
* Cuts the mustard on [`CSSStyleSheet.prototype.replaceSync`](https://caniuse.com/mdn-api_cssstylesheet_replacesync)