[HN Gopher] RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components
       ___________________________________________________________________
        
       RubyUI (Former PhlexUI): Ruby Gem for RubyUI Components
        
       Author : ksec
       Score  : 105 points
       Date   : 2025-04-01 15:39 UTC (7 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | bdcravens wrote:
       | Looks interesting, but I wish there was a way to alias the
       | component names, since every component class, some of which have
       | common names, take root in the global namespace. (though I
       | suspect that easily enough done manually)
        
         | a-priori wrote:
         | It's basically a code generator for adding standard Phlex
         | components to your project, so once you've added a component to
         | your application you can modify it any way you want.
        
         | joeldrapper wrote:
         | They're not in the root namespace. They are instance methods
         | (on the instance of the component) that start with a capital
         | letter. https://www.phlex.fun/components/kits.html
        
       | desireco42 wrote:
       | Looks really good and I am happy to see many interesting in Ruby
       | world...
        
       | budu wrote:
       | The RubyUI team is doing a fantastic job. This gem is now one of
       | the first ones I add to a new project. Thanks for your work!
        
       | dzonga wrote:
       | this looks dope. has anyone built anything substantial with phlex
       | ?
        
         | timwis wrote:
         | Yep! https://magicnotes.ai It's pretty neat once you get over
         | the initial weirdness. Unlocks a lot of potential. But because
         | it's new, there are fewer conventions, so you have to come up
         | with them and be consistent.
        
         | joeldrapper wrote:
         | I believe Clearscope is the largest app using Phlex views
         | exclusively, with 454 components and counting. There's a list
         | of some other users here.
         | https://www.phlex.fun/project/community.html#who-s-using-phl...
        
         | aliosm wrote:
         | I'm using Phlex/RubyUI primarily in my project
         | https://baheth.ieasybooks.com and it is amazing in both
         | performance and developer experience.
        
       | drumpkid wrote:
       | I'm impressed by this project's progress. It's more than just a
       | render library. Although they claim it's 12x faster than ERB, but
       | I couldn't find their benchmark.
        
         | fidrelity wrote:
         | I believe it's referencing this:
         | https://github.com/KonnorRogers/view-layer-benchmarks
        
           | byroot wrote:
           | Can't believe this still has to be debunked. No Phlex
           | certainly isn't 12x faster than ERB. It's noticeably slower
           | than ERB, e.g.: https://github.com/KonnorRogers/view-layer-
           | benchmarks/commit...
           | 
           | In some extreme scenarios with tons of very small partials,
           | it can win against _Action View_ because the Action View
           | partial lookup is significant overhead.
        
             | tenderlove wrote:
             | It says on the website it's 12x faster so it must be true!
             | 
             | https://rubyui.com
        
               | joeldrapper wrote:
               | It probably is (or at least was) faster than ActionView
               | if you use lots of small partials, but it is not faster
               | than ERB since it is not compiled. It generates HTML at
               | about 1.6gbps per core on my laptop so probably fast
               | enough for most things.
        
             | joeldrapper wrote:
             | In my experience, it's not an extreme scenario to render
             | several thousand components in a single view.
             | 
             | I think you're looking at this from the perspective of
             | having maybe a partial for your header and another for your
             | footer. The way you build views in Phlex is you would have
             | a component not just for the header but also the nav, each
             | item in the nav, and each icon in each item.
             | 
             | We can argue about whether that level of abstraction and
             | reuse is worth it, but the fact is ActionView gets very
             | slow when you build views like that composing thousands of
             | partials -- and for people who want to build views like
             | that, it matters.
             | 
             | Still, I think these "12x faster" comparisons are silly. If
             | ActionView was just as fast at rendering thousands of small
             | components, I'd still pick Phlex for the developer
             | experience. I enjoy writing Ruby, not toggling between Ruby
             | and HTML.
        
       | daviding wrote:
       | Interesting stuff. Unsure about the Phlex approach but could be
       | worth a go.
       | 
       | Didn't have any luck with the Date Picker component demo page (no
       | pop up or validation?), and that's my usual go-to for seeing how
       | these libraries are doing.
        
       | this_is_madness wrote:
       | the fact that this mentions Tailwind already signifies that its
       | target audience is 10 year olds
       | 
       | edit: yeah, after reading more, this is an affront against
       | nature. forget about separation of content and presentation, now
       | you can even throw your backend into the dumpster fire!
        
       | ramesh31 wrote:
       | Really gorgeous components. I cant say I understand who would use
       | this or why... but this is a good thing.
        
       | GenericCanadian wrote:
       | Phlex is an amazing project. Makes frontend fun again. I've built
       | my own UI library using DaisyUI and Tailwindcss that we use in
       | all our Rails projects: https://github.com/inhouse-work/protos
       | 
       | It cannot be overstated how nice it is to move away from erb and
       | into pure ruby. Private methods as partials is a game changer for
       | refactoring your UI.
        
         | jherdman wrote:
         | Have you had much luck with slots? I have a project using View
         | Components that leverages slots. I've tried migrating to Phlex,
         | but the lack of explicit slot support has been a bit
         | frustrating.
        
           | GenericCanadian wrote:
           | Slots are pretty easy in Phlex. Have a look at the README in
           | the repo I linked for an idea. I just create `with_column` or
           | `with_header` methods that take a block and store it.
           | 
           | To create them declaratively (not needing to call them in a
           | set order) you just create a module that defines
           | `before_template` and calls `vanish`: https://www.phlex.fun/m
           | iscellaneous/v2-upgrade.html#removed-...
        
         | freedomben wrote:
         | I increasingly wonder if I'm the only one left who genuinely
         | likes erb :-D
         | 
         | Not a fan of the rails erb helper methods though, so maybe it
         | doesn't count. I almost exclusively use it outside of rails now
        
           | barefootford wrote:
           | I don't know if I'm a fan but I've almost never had erb be
           | the problem in a Rails app. The LLMs can work with it easily.
           | Don't need to bring in extensions to work with major text
           | editors. Sticking with ERB for now.
        
           | GenericCanadian wrote:
           | I found using partials between projects to be a headache. I
           | wanted a way to standardize my UI for accessibility across
           | all projects and not have to re-implement the same standards
           | over and over. It's nice to be able to package the UI up into
           | a gem and keep it maintained everywhere.
           | 
           | It's got a nice path for incremental adoption, so there is no
           | need to go all-in unless you want to. Personally my Rails
           | projects are all 95%+ ruby now.
           | 
           | Another nice knock off effect is that the LSP and integration
           | with my IDE (neovim) is much nicer with Phlex components than
           | it is with ERB.
           | 
           | I also think personally I don't like "magic" spaces like ERB
           | where its hard for me to follow the code path. How does ERB
           | manage multiline blocks with html in them? Hard to
           | understand, harder to explain. To me it feels like there is
           | less to worry about in Phlex where I'm thinking more in Ruby,
           | less in the specifics of the view context.
        
       ___________________________________________________________________
       (page generated 2025-04-01 23:00 UTC)