DEV Community

Cover image for clsx for Rails views

clsx for Rails views

Leonid Svyatov on March 03, 2024

Hey, fellow Rubyists! Have you ever found yourself wrestling with conditional class strings in your Rails views? Juggling string interpolation, co...
Collapse
 
adrienpoly profile image
Adrien Poly

Hello

I like this pattern, this being said what is the main difference with rails class_names helper ?

Collapse
 
svyatov profile image
Leonid Svyatov

Hey! That's actually a great question because somehow I didn't know about the class_names helper :) I briefly looked at the implementation, and it seems the performance might be the most significant difference.

I will make a more thorough comparison. Thank you for bringing my attention to it!