🖼️Customize the views
How to change the views using LightningRails partials/components
Using Tailwind Front-end Components in Your Ruby on Rails Application
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.
Using DaisyUI Components
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!
Rendering Tailwind Components included by default in Lightning Rails
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) 🤯:
(Optional) - Passing Instance Variables to Components
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 thelabel
andcolor
variables to customize the button:
Last updated