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

rami-table-ui-component

v1.0.0

Published

A reusable, configurable table component built with React and styled using Tailwind CSS. This component dynamically adjusts its height and supports conditional scrolling based on the number of rows provided.

Downloads

64

Readme

Table Component

A reusable, configurable table component built with React and styled using Tailwind CSS. This component dynamically adjusts its height and supports conditional scrolling based on the number of rows provided.

Prerequisites

To use this component, ensure your project meets the following requirements:

  • React: This component is designed to work in a React environment.
  • Tailwind CSS: Tailwind CSS should be set up in your project. See instructions below for adding Tailwind CSS.

Installation

  1. Install the Table Component

    First, add the Table component package to your project:

    npm install rami-table-component
  2. Add Tailwind CSS

    If you haven’t already, set up Tailwind CSS in your project:

    npm install -D tailwindcss postcss autoprefixer
    npx tailwindcss init -p

    Update tailwind.config.js to include the Table component's files for Tailwind’s content option. This ensures unused Tailwind CSS classes are purged in production:

    /** @type {import('tailwindcss').Config} */
    module.exports = {
      content: [
        "./src/**/*.{js,jsx,ts,tsx}",
        "./node_modules/rami-table-component/dist/**/*.{js,ts,jsx,tsx}" // Include component files
      ],
      theme: {
        extend: {},
      },
      plugins: [],
    };
  3. Import Tailwind CSS

    In your main CSS file (e.g., src/index.css), add the following Tailwind directives to load its styles:

    @tailwind base;
    @tailwind components;
    @tailwind utilities;

Usage

Once installed, you can use the Table component by importing it into your project and providing it with the necessary props.

Example

import React from 'react';
import Table from 'rami-table-component';

const App = () => {
  const data = [
    { name: "Rami  Mahfoud", age: 36, email: "[email protected]", city: "Erlangen" },
    { name: "Sarah Müller", age: 30, email: "[email protected]", city: "Berlin" },
    // Add more data as needed
  ];

  return (
    <div className="p-4">
      <h1 className="text-2xl font-bold mb-4">User Table</h1>
      <Table
        list={data}
        headers={["name", "age", "email", "city"]}
        rows={5} // Number of rows to display before scrolling
      />
    </div>
  );
};

export default App;

Props

The Table component accepts the following props:

  • list (required): An array of objects representing table data.
  • headers (optional): An array of strings to display as table headers.
  • rows (optional): A number specifying how many rows to display before the table becomes scrollable.

Example Data

Here’s an example of the list data structure:

const data = [
   { name: "John", age: 36, email: "[email protected]", city: "Milan" },
   { name: "Jana Müller", age: 30, email: "[email protected]", city: "Berlin" },
  // More entries...
];

You can also include JS element in the data

const data = [
   { name: <strong>John </strong>, age: 36, email: "[email protected]", city: "Milan" },
   { name: <strong> Sarah Müller</strong>, age: 30, email: "[email protected]", city: "Berlin" },
  // More entries...
];

Customization

The Table component is built using Tailwind CSS classes, making it easy to extend and override styles within your own project. Customize by applying additional classes as needed in your Tailwind setup.

Test the component

If you want to update the component you can test it by run

npm run test