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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nalu-table

v1.0.18

Published

A customizable React data table component with sorting, filtering, and pagination features

Downloads

465

Readme

Nalu Table

A modern, customizable React table component with built-in themes, pagination, and advanced features. Perfect for creating beautiful and functional data tables in your React applications.

NPM Version License

Features

  • 🎨 Theme variants (Sapphire & Crimson)
  • 🌗 Light and dark mode
  • 📱 Responsive design
  • ⚡ Pagination
  • 🔄 Dynamic sorting
  • ✨ Row selection
  • 📑 Tab system
  • 🎯 Custom actions
  • 🖼️ Custom logo support

Installation

1. Install the package

npm install nalu-table
# or
yarn add nalu-table

2. Tailwind CSS Requirement

This component requires Tailwind CSS to be installed and configured in your project. If you haven't already set up Tailwind CSS, follow these steps:

  1. Install Tailwind CSS
npm install -D tailwindcss postcss autoprefixer
# or
yarn add -D tailwindcss postcss autoprefixer
  1. Initialize Tailwind CSS
npx tailwindcss init -p
  1. Configure your tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/**/*.{js,jsx,ts,tsx}",
    "./node_modules/nalu-table/**/*.{js,jsx}", // Add this line to include nalu-table components
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};
  1. Add Tailwind's directives to your CSS
/* In your main CSS file */
@tailwind base;
@tailwind components;
@tailwind utilities;

3. Start using the component

import NaluTable from "nalu-table";
import "nalu-table/dist/style.css"; //Recommended for best visual experience

// Your component code

⚠️ Important: The table component will not be styled correctly if Tailwind CSS is not properly installed and configured in your project.

Quick Start

import NaluTable from "nalu-table";
import "nalu-table/dist/style.css"; //Recommended for best visual experience


function App() {
 const tableData = {
    tabs: [
      { title: 'Tab 1', quantity: 10, checked: true, special: true },
      { title: 'Tab 2', quantity: 20, checked: false }, special: false}
    ],
    tableInfo: {
      columns: [
        { header: 'Name', ref: 'name', alignment: 'left', ordering: true },
        { header: 'Price', ref: 'price', alignment: 'right', ordering: true },
      ],
      items: [
        { id: 1, name: 'Item 1', price: 10.99 },
        { id: 2, name: 'Item 2', price: 20.99 },
      ],
    },
  };

  return (
    <NaluTable
      tableData={tableData}
      header=true
      variant="sapphire"
      theme="light"
    />
  );
}

Props

| Prop | Type | Default | Description | | ----------------- | --------- | ---------------------------- | --------------------------------------------------- | | tableData | array | [] | Required. Array of data to display in the table | | header | boolean | true | Search header visibility | | plusButton | boolean | true | Custom add button component | | totalItems | number | 0 | Total number of items for pagination | | itemsPerPage | number | 10 | Number of items per page | | currentPageProp | number | 1 | Current page number | | loading | boolean | false | Loading state of the table | | size | string | "default" | Table size variant | | variant | string | "sapphire" | Visual variant of the table | | theme | string | "light" | Color theme ("light" or "dark") | | modalTitle | string | "" | Title for the modal | | selectedTab | string | "" | Currently selected tab | | activeTab | string | "" | Currently active tab | | language | string | "en" | Table language (only 'en' and 'pt-br'') | | minWidth | number | 1200 | Minimum content width (ScrollBar) | | brandlogo | string | "https://placehold.co/400" | URL for the logo image |

Event Handlers

| Prop | Type | Default | Description | | ----------------------- | ---------- | ---------- | --------------------------------- | | addItemFunction | function | () => {} | Handler for adding new items | | viewItemFunction | function | () => {} | Handler for viewing items | | editItemFunction | function | () => {} | Handler for editing items | | removeItemFunction | function | () => {} | Handler for removing items | | handlePageChange | function | () => {} | Handler for page changes | | handleTabChange | function | () => {} | Handler for tab changes | | handleSelectionChange | function | null | Handler for row selection changes | | handleSaveTabs | function | () => {} | Handler for saving tab changes |

Examples

Basic Table

<NaluTable
  tableData={data}
  header=true
  variant="crimson"
  theme="light"
/>

Table with Custom Actions

<NaluTable
  tableData={data}
  header=true
  plusButton={() => console.log('Do something')}
  addItemFunction={() => console.log('Add:', id)}
  editItemFunction={(id) => console.log('Edit:', id)}
  removeItemFunction={(id) => console.log('Remove:', id)}
/>

Paginated Table with Selection

<NaluTable
  tableData={data}
  header=true
  totalItems={100}
  itemsPerPage={20}
  handlePageChange={(page) => console.log('Page:', page)}
  handleSelectionChange={(selected) => console.log('Selected:', selected)} // returns an array of items selected in the checkbox
/>

Custom Themed Table

<NaluTable
  tableData={data}
  header=true
  variant="sapphire"
  theme="dark"
  brandLogo="path/to/your/logo.png"
/>

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © William Silva