
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
svelte-tailwind-table-types
Advanced tools
A Svelte component for rendering a dynamic table using tailwind, now with types !
The last Svelte Table library you will ever need. A Svelte component for rendering a dynamic table using tailwind CSS
This is a hard fork of svelte-tailwind-table since the original repository on GitLab couldn't be reached and I wanted to add types and SvelteKit-style imports.
showHeaderOptions, theme, onRowClickFunction, interactiveRows, activeRow, rowBorderTouch, borderRadius, numbersSmallDemo GIF 👇(OLD)
Tailwind css in required for the table to be styled properly
npm install svelte-tailwind-table
<script>
import Table from 'svelte-tailwind-table';
</script>
<Table colData={...} rowData={...}/>
| Prop Name | Data Type | Default value |
|---|---|---|
colData | array | example with all data types |
rowData | array | example with 2 row values |
theme | string | outline |
showSearchBar | boolean | true |
searchStyles | string | "" |
searchText | string | "" |
showFilter | boolean | true |
filterButtonColor | string | "red" |
showHeaderIcons | boolean | true |
showHeaderOptions | boolean | true |
headerEditable | boolean | true |
borderBetweenColumns | boolean | true |
numberAlign | string | "right" |
allCenter | boolean | false |
pagination | boolean | true |
paginationRows | number | 10 |
currentPage | number | 1 |
paginationType | string | default |
selectAllMenu | boolean | true |
onClickFunction | function | ()={} |
onRowClickFunction | function | ()={} |
interactiveRows | boolean | false |
interactiveRowColor | string | "gray" |
activeRow | number | 0 |
rowBorderTouch | boolean | true |
borderRadius | text | xl |
numbersSmall | boolean | true |
overrideClasses | string | "" |
colDataA 2-Dimensional array with the following properties:
colData = [
["Data type", {heading: "Column 1 heading", data:{...}}],
["Data type", {heading: "Column 2 heading", data:{...}}],
]
Refer to Datatypes for information regarding the data:{...}
rowDataA 2-Dimensional array with the following properties:
rowData = [
[ //row 1
{value: "The value", editable: true, href: "This is optional"}, //column 1 value
{value: "The value", editable: true, href: "hyperlink for a cell"}, //column 2 value
],
[ //row 2
{value: "The value", editable: true}, //column 1 value
{value: "The value", editable: true}, //column 2 value
]
]
Refer to Data Types for information regarding the The value
themeThe theme of the table.
outline or filled makes the header background color white or grey.
borderless makes the table borderless and transparent.
showSearchBarA boolean value to determine if the default search bar is shown or not.
searchStylesA string value to override the styling of the search bar.
searchTextA string value to set the searched text for the search bar.
showFilterA boolean value to determine if the default filter is shown or not.
filterButtonColorA string value to set the color of the filter button.
showHeaderIconsA boolean value to determine if the header icons are shown or not.
showHeaderOptionsA boolean value to determine if the header options are shown or not.
headerEditableA boolean value to determine if the header is editable or not.
borderBetweenColumnsA boolean value to determine if the border between columns is shown or not.
numberAlignA string value to set the alignment of the number column ("right" or "left").
allCenterA boolean value to determine if the cell values are centered or not.
paginationA boolean value to determine if the pagination is done or not.
paginationRowsAn integer value to set the number of rows per page.
currentPageAn integer value to set the current page.
paginationTypeA string value to set the type of pagination.
default or detailed - Detailed shows the number current showing data
Theme of pagination is determined by the theme of the table.
selectAllMenuA boolean value to determine if the select all box is shown or not.
onClickFunctionA function to call when a cell is clicked on The function needs to be of format
function yourFunctionName(event, cellData, colIndex, rowIndex){
// do anything using the params
}
onRowClickFunctionA function to call when a row is clicked on (only if interactiveRows is set to true)
The function needs to be of format
function yourFunctionName(event, rowIndex){
// do anything using the params
}
interactiveRowsA boolean value to determine if the rows are interactive or not.
interactiveRowColorA string value to set the color of the interactive rows on active and hover.
activeRowAn integer value to set the active row. This is only used if interactiveRows is set to true.
rowBorderTouchA boolean value to determine if the row borders are touching the edges or are disconnected.
borderRadiusA string value to set the border radius of the table.
One of "none", "sm", "md", "lg", "xl", "2xl", "3xl", "4xl", "5xl", "6xl", "7xl", "full"
numbersSmallA boolean value to determine if the numbers are small or not. Makes the minimum width of the number column smaller or larger.
overrideClassesA string value to override the default classes.
data: {
align: "right"/"left"/"center", //optional
iconAlign: "right"/"left"/"center", //optional
iconSvg: "svg as string for overriding default svg", //optional
showIcon: true/false, //optional
}
data: {}
value: "The value"
data: {checked: true}
value: boolean(false/true)
data: {}
value: 123
data: {
options: [
{text: "Option 1", color: "#c3c3c3"}, // color is optional
{text: "Option 2", color: "#c4c4c4"}, // When not provided random colors will be assigned
{text: "Option 3", color: "#c5c5c5"}, // random colors will be taken from predefined light colors
]
}
value: {text: "Option 1", color: "#c3c3c3"}
data: {
options: [
{text: "Option 1"}, // color is optional here also
{text: "Option 2"},
{text: "Option 3"},
]
}
value: [
{text: "Option 1"},
{text: "Option 2"}
] // make sure to use same object value as in options
data: {}
value: [
{
link:"https://via.placeholder.com/150",
href:"https://www.example.com"
}, //image 1
{
link:"https://via.placeholder.com/150",
href:"https://www.example.com"
}, //image 2
]
data: {}
value: "2003-02-19"
data: {}
value: "12:00"
data: {
svg: `<svg></svg>`, // default row svg string
}
value: `<svg></svg>`/"" // override row svg string otherwise ""
The above svg overrides are for row data and not the default header icon. Use iconSvg prop for that
data: {
component: CustomComponent, // Custom Component directly from import
defaultProps: { // props to pass to the component
prop1: "value",
prop2: "value"
}
}
value: {
props: { // props to override default props
prop1: "value",
prop2: "value"
}
}
To fire and use events on custom components, dispatch an event named as "event" from the component and use on:customEvent prop on Table component; The details passed on to the "event" dispatch will be e.detail.e for the Table listener
<!-- CustomComponent.svelte -->
<script>
import {createEventDispatcher} from "svelte";
const dispatch = createEventDispatcher();
</script>
<div on:click={(e)=>{
dispatch("event", {
active: false
})
}}>
<!-- ... -->
</div>
<!-- Main.svelte -->
<Table on:customEvent={(e)=>{
console.log(e.detail.e) // logs {active: false}
}}/>
Contact me at LinkedIn or Github or priyavkaneria@gmail.com
FAQs
A Svelte component for rendering a dynamic table using tailwind, now with types !
The npm package svelte-tailwind-table-types receives a total of 5 weekly downloads. As such, svelte-tailwind-table-types popularity was classified as not popular.
We found that svelte-tailwind-table-types demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.