Wiretables: tables for Laravel and Livewire written in Blade
Table packages for Livewire usually define the columns in PHP arrays, which is comfortable until one cell needs something the configuration did not plan for. Wiretables goes the other way: you write the table in Blade, cell by cell, and the package brings the pieces, their look and the behaviour every list repeats. Columns that hide or stack into cards on a phone, header sorting kept in the URL,…
Wiretables is a package for Laravel and Livewire that allows developers to create tables using Blade. This innovative approach eliminates the need for PHP arrays to define columns, which can become cumbersome when a cell requires functionality not initially planned. Instead, Wiretables enables you to write the table in Blade, cell by cell, integrating both its appearance and behavior seamlessly.
One of the key features of Wiretables is its responsiveness. Columns can hide or stack into cards on mobile devices, ensuring a smooth and adaptable user experience across various screen sizes. Additionally, the package offers a header sorting system that is maintained in the URL, providing users with an intuitive way to sort data.
Wiretables also includes a load more feature, which is particularly useful for lists that grow over time. This feature automatically requests everything up to the current page from the start, ensuring that newly added or removed records are never repeated or lost. Each theme in Wiretables is a separate file, allowing developers to add themes without increasing the overall CSS size.
Developer experience is prioritized in Wiretables, as it is a straightforward Laravel package. Installation is as simple as requiring it with Composer and publishing the CSS. With Vite, developers can import the necessary CSS directly from the package's resources. Themes are also compatible with Tailwind and Bootstrap, providing flexibility in styling.
Sorting and load more functionalities are handled via Livewire traits, ensuring that sorting keys and directions are maintained in the URL. This prevents any unauthorized manipulation of the sort order. Additionally, the row menu lives in x-wiretable.menu, a ⋯ button that fits on any screen and is anchored to the button for easy access, even in scrolling tables or modals.
In summary, Wiretables offers a powerful, flexible, and user-friendly solution for creating responsive tables in Laravel and Livewire projects, without the constraints of traditional PHP arrays and with a focus on modern web development best practices.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.