TTT Studios is OPEN. Our team will continue to solve business problems remotely during this pandemic.

Introducing our new Laravel package: Alpinejs Table

Alpinejs Table logo for blog
fb twitter linkedin
link
Copied!

Alpine.js has proven itself to be a very useful framework especially if your major concern is two-way data binding. Its minimal and lightweight nature lends itself well to creating simple components that work within a larger framework. 

It works out of the box without any installation or a third party library or a special environment. We chose to use it in parts of one of our most recent projects as it saved us time and wasn’t nearly as resource heavy as Vue.js and React.js. 

We used Alpine.js to develop a new table component on a recent build that will be reusable on future projects and we gave it the very creative name: Alpinejs Table. You can find the plugin tutorial on our GitHub, and we hope that you will find it useful. 

Why now?

We’ve had our eye on Alpine.js for a while now given the many benefits it offered under the right environment. As with many new frameworks, unfortunately, there can be many unforeseen issues that pop up, and too small of a community to offer enough viable solutions. 

With Alpine.js, there was a major bug that broke the logic inside “nested loops”. This caused the framework to be practically unusable for us and for many others. Since the bug was fixed back in March this year, we’re finding ways of incorporating it into our projects. 

Benefits

It’s Lightweight

As React.js and Vue.js have gained popularity and become fuller frameworks, they became too heavy to inject into a different framework like Laravel. This is where Alpine.js shines. Any website that is not using a full JavaScript framework can benefit from the use of Alpine.js. You can add components as needed without it being resource heavy. 

It’s Flexible

I’ve seen Alpine.js referred to as a JavaScript swiss army knife, and I’d have to agree. It’s very flexible, and great for injecting elements into your existing DOM. In the case of Alpinejs Table, you can easily set up different colours for columns and set up conditional formatting for different elements. It’s also very easy to inject buttons or links that require the data of that column.

Limitations

Alpine.js

Despite it being useful in a lot of situations, like any framework, Alpine.js has its drawbacks. It doesn’t support components in a native way. If it did, it would be upgraded from a tool to an ecosystem. You’d be able to pick whatever you needed from thousands of components and build from it like lego blocks. With Vue.js and React.js, you can enjoy the true benefits of open source code without reinventing the wheel. 

Alpinejs Table

It works best with components that aren’t pulling a ton of data. In the case of Alpinejs Table, it works well if you’re not working with a large amount of data. This is because all the data in the table gets loaded in by default. If you’re working with a lot of data, the table will take up a lot of memory and load very slowly.

In future iterations of this library, we plan on looking at ways of accommodating more data. Some possibilities include separating data into pagination and providing the ability to load page by page.

The TTT technical team is constantly working on creating more open source libraries and tools to help the community. You can check out our other libraries PaginatableList and OTP Input for React Native on GitHub. Be sure to follow us on social media and subscribe to our monthly newsletter “The Edge” to keep up to date with our future library releases. 

Recent posts