1.0.2 • Published 10 months ago

tailwind-table v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Tailwind Table

Downloads Version Contributors

Simple usage customizable table with TailwindCSS e Typescript

How to use?

The Table component can recives this parameters:

  • data:

    Array with datas to render on table;

    • Example:
    [
      {
        name: "Sofia Oliveira",
        email: "sofia.oliveira@example.com",
        status: "Ativo",
        role: "Admin",
      },
      {
        name: "João Santos",
        email: "joao.santos@example.com",
        status: "Suspenso",
        role: "Usuário",
      },
    ];
  • columns:

    Array with columns that will be displayed in the table.

    • Example:
    [
      {
        title: "Nome", // Title of column that will be displayed.
        key: "name", // Key of data object that represents this column.
      },
      {
        title: "Email",
        key: "email",
      },
    ];
  • pagination:

    Optional. Depending on your pagination method, you can use some techniques to achieve the following information.

    • Example:
    {
        currentPage: number;
        pagesTotal: number;
        itemsPerPageProps: PaginationItemsPerPageProps;
        onClickPrev: MouseEventHandler<HTMLButtonElement>;
        onClickNext: MouseEventHandler<HTMLButtonElement>;
    }

    The first two attributes are self-explanatory. The last two are callback functions that will be executed when clicking on the pagination buttons.

    PaginationItemsPerPageProps are optional and can recive this props:

    {
        itemsPerPage: "10";
        text: "Usuários por página";
        setItemsPerPage: (itemsPerPage) => setState(itemsPerPage);
        options: [5,10,20,50];
        classNames: {
    	    text: "",
    	    input: "",
    	    div: "",
    	};
    }
  • paginationTexts:

    Optional. If you prefer, pass the texts that will appear in the pagination.

    • Example:
    {
        pageText: "Página", // Page
        prevText: "Anterior", // Previous
        nextText: "Próxima", // Next
    }
  • classNames:

    Optional. Object that can contain: table, thead, tbody. This add your custom className (tailwind style) to this elements of table.

    • Example:
    {
        table: "rounded-lg",
        thead: "text-gray-800",
        tbody: "bg-white",
    }
  • tableHeadClassNames:

    Optional. Object that can contain: tr, th. This add your custom className (tailwind style) to this elements of table.

  • tableRowsClassNames:

    Optional. Object that can contain: tr, td. This add your custom className (tailwind style) to this elements of table.

You can see the result here.

Contributing

Feel free to contribute 😁

1.0.2

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.0

11 months ago

0.0.28

11 months ago

0.0.27

11 months ago

0.0.26

11 months ago

0.0.25

11 months ago

0.0.24

11 months ago

0.0.23

11 months ago

0.0.22

11 months ago

0.0.21

11 months ago

0.0.20

11 months ago

0.0.19

11 months ago

0.0.18

11 months ago

0.0.17

11 months ago

0.0.16

11 months ago

0.0.15

11 months ago

0.0.14

11 months ago

0.0.13

11 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.1.0

11 months ago

0.0.1

11 months ago