fteschke
Phoenix LiveView + HeadlessUI
I wrote a short description of how to use HeadlessUI components with LiveView:
Tailored to HeadlessUI, but in fact not HeadlesUI specific, but applicable to React components in general.
Approach:
- React Component
- Wrapped in Web Component that handles server->client (attribute changes) and client-server (events) communication
- Rendered to light DOM (not shadow DOM, due to lacking HeadlessUI support)
- micro LiveView Hook with glue code push LiveView events to server
Pros:
- integrates well with minimal esbuild assets pipeline
- web component is a good interface boundary for LiveView / “custom” Javascript
- sprinkle minimal amounts of Javascript where necessary
Cons:
- use with caution, prefer LiveView
Phoenix.LiveView.JSbindings where sufficient
Do you use similar techniques? What are your experiences?
Are there better ways of implementing this approach?
Most Liked
LostKobrakai
There had been an interesting talk at last years elixir conf: https://www.youtube.com/watch?v=xXWyOy9XdA8
I don’t think they’re just useful for input fields, but more anything interactive. They’re useful wherever you want to abstract some behaviour without enforcing how the UI around said behaviours looks like.
Last Post!
fteschke
Nope.
Great talk, wasn’t aware of that. I would look at my post as a port of Chris’s ideas to react/JSX world, where he focuses more on lit.
I especially like his call for simplicity by avoiding JS rendering, shadow DOM etc. if not needed.
Popular in Discussions
Other popular topics
Latest Phoenix Threads
Chat & Discussions>Discussions
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









