🖼️Customize the views
How to change the views using LightningRails partials/components
Last updated
How to change the views using LightningRails partials/components
Last updated
In our Ruby on Rails application, we utilize Tailwind CSS for styling, complemented by components from the DaisyUI library. You will find the custom Tailwind components organized in the views > components
folder.
We use DaisyUI to enhance our Tailwind components with pre-designed UI elements. DaisyUI provides various components that you can easily integrate into your application, allowing for rapid and responsive UI design.
You can explore the full range of DaisyUI components on their website: DaisyUI.
Feel free to check out their library and incorporate any components that fit your design needs into our application!
To include Tailwind components in your views, simply use the render
ERB tag. This makes it super easy to integrate components throughout your application.
How easy is it? The entire LightningRails home page is built with just 7 lines of code (already included in the boilerplate) 🤯:
If you have instance variables in your controller and want to pass them to a button component, here's how you can do it:
Pass any variable to the component:
When rendering the button component in your view:
Access the variables in your component:
In your _button.html.erb
partial, you can now use the label
and color
variables to customize the button: