An open API service indexing awesome lists of open source software.

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.

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)