npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

sveltekit-datagrid

v0.0.3

Published

![Version](https://img.shields.io/badge/version-1.0.0-blue) ![License](https://img.shields.io/badge/license-MIT-green)

Downloads

6

Readme

🚀 SvelteKit DataGrid Component 🚀

Version License

A powerful and customizable DataGrid component for SvelteKit applications. Built with TypeScript support, featuring sorting, filtering, pagination, export options, and more!

📦 View on GitHub


🌟 Features

TypeScript Ready
Pagination & Sorting
Column Filtering
Data Export (PDF, Excel, CSV, etc.)
Row Selection & Grouping
Custom Cell Formatting
Dynamic Data Updates
Responsive Design


📦 Installation

npm install sveltekit-datagrid docx jspdf jspdf-autotable xlsx 
npm install tailwindcss @tailwindcss/vite
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
  plugins: [
    tailwindcss(),
    sveltekit(),
  ],
});

app.css @import "tailwindcss";

<script>
  let { children } = $props();
  import "../app.css";
</script>
{@render children()}

🛠️ Quick Start

1. Import the Component

<script lang="ts">
  import { DataGrid } from "sveltekit-datagrid";
</script>

2. Define Your Data

interface User {
  id: number;
  name: string;
  email: string;
  role: string;
  status: "Active" | "Inactive";
  lastLogin: string;
}

let users = $state<User[]>([
  {
    id: 1,
    name: "John Doe",
    email: "[email protected]",
    role: "Admin",
    status: "Active",
    lastLogin: "2023-11-15",
  },
  // ... more data
]);

3. Configure Columns

const columns: Column<User>[] = [
    { selectable: true }, // Checkbox column
    { field: "id", header: "ID" },
    { field: "name", header: "Name" },
    { field: "email", header: "Email" },
    {
        field: "role",
        header: "Role",
    },
    {
        field: "status",
        header: "Status",
        width: "100px",
        filterable: true,
        sortable: true,
        format: (value: string) => {
            const color = value === "Active" ? "green" : "red";
            return `<span style="color: ${color}; font-weight: bold;">${value}</span>`;
        },
    },
    {
        field: "lastLogin",
        header: "Last Login",
        format: (value: string) => {
            const date = new Date(value);
            return date.toLocaleDateString();
        },
    },
];

4. Add Export Options

const exportOptions: ExportOption[] = [
    { label: "Export to PDF", format: "pdf", enabled: true },
    { label: "Export to XLS", format: "xls", enabled: true },
    { label: "Export to XLSX", format: "xlsx", enabled: true },
    { label: "Export to DOCX", format: "docx", enabled: true },
    { label: "Export to RTF", format: "rtf", enabled: true },
    { label: "Export to CSV", format: "csv", enabled: true },
];

5. Use the Component

<DataGrid
    data={users}
    {columns}
    pageSize={10}
    showPagination={true}
    showFilter={true}
    showSort={true}
    {exportOptions}
    allowGrouping={true}
    onRowClick={(rowData, event) => {
        console.log("Row clicked:", rowData);
        // Access any field from the row
        console.log("ID:", rowData.id);
        // Perform actions based on the row data
    }}
>
    {#snippet toolbar()}
        <button class="dx-button" onclick={addNewUser}> Add User </button>
    {/snippet}
</DataGrid>

🎨 Customization

Column Configuration Options

| Property | Description | Type | |---------------|--------------------------------------|-------------------------------| | field | Data field name | keyof T | | header | Column header text | string | | width | Column width | string (e.g., "150px") | | sortable | Enable sorting | boolean | | filterable | Enable filtering | boolean | | format | Custom cell formatting function | (value: any, row: T) => string |

Export Options

Supports multiple formats:
pdf, xls, xlsx, docx, rtf, csv


📚 Tutorial for Beginners

Step 1: Create New SvelteKit Project

npm sv create my-app
cd my-app
npm install

Step 2: Add Sample Data

Create a data.js file with mock data (like the user example above)

Step 3: Basic Implementation

<script>
  import { DataGrid } from "@joirg_dev98/makeit-datagrid";
  import { users } from "./data.js";
  
  const columns = [
    { field: "name", header: "Name" },
    { field: "email", header: "Email" },
    // Add more columns
  ];
</script>

<DataGrid data={users} {columns} />

Step 4: Add Features

  • Pagination: Add pageSize={10}
  • Filtering: Add showFilter={true}
  • Export: Add exportOptions={[...]}

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a pull request

Want to contribute or check out the code? Visit our GitHub repository!


📄 License

This project is licensed under the MIT License - see the LICENSE file for details


Made with ❤️ by Isaac R.
Need help? Open an issue or contact me at [[email protected]]


This adds the necessary Tailwind CSS setup instructions that are required for the DataGrid component to work properly.