svelte-table-layout
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Svelte Table Layout

A dynamic table layout for Svelte, a drop-in replacement for HTML tables that use CSS grid under the hood. It lets you easily style columns and rows even if there are cells with nontrivial colspan & rowspan.

<Table class="my-table">
	<Row style="background: gray">
		<Cell>grey</Cell>
		<Cell>row</Cell>
		<Cell>with no decoration</Cell>
	</Row>
	<Row style="background: pink; border: 1px solid red;">
		<Cell colspan={2}>pink row</Cell>
		<Cell>with red border</Cell>
	</Row>
</Table>

<style>
	/* make all cells that intersect the third column bold */
	:global(.my-table [data-column~='3']) {
		font-weight: bold;
	}
</style>

It also supports colspan=row to make cells span the entire row, and lets you align the columns of two different tables.

<Table bind:computedColumnWidths={columns}>
	<Row>
		<Cell>a-really-long-cell</Cell>
		<Cell>normal-cell</Cell>
		<Cell>xd</Cell>
	</Row>
	<Row>
		<Cell colspan="row">lorem</Cell>
	</Row>
</Table>

<Table {columns}>
	<Row>
		<Cell>a</Cell>
		<Cell>b</Cell>
		<Cell>c</Cell>
	</Row>
	<Row>
		<Cell>d</Cell>
		<Cell>e</Cell>
		<Cell>f</Cell>
	</Row>
</Table>

Readme

Keywords

none

Package Sidebar

Install

npm i svelte-table-layout

Weekly Downloads

29

Version

1.0.0

License

MIT

Unpacked Size

27.1 kB

Total Files

14

Last publish

Collaborators

  • c.sha