fbutano
Using Core Components <.table> with Flop sorting in LiveView + streams?
Hi all, I’m trying to maintain a consistent UI by using the standard Core Components <.table> generated by Phoenix (with DaisyUI styling), but I also want to integrate Flop sorting into the headers. At the same time, I’m using LiveView streams (phx-update=“stream”) to update only the table body.
Requirements:
1. Use Flop for sorting, so each header becomes clickable and triggers /admin/users?order_by=email&…
2. Keep the Core Components <.table>, without rewriting the whole table manually.
3. Keep using LiveView streams for the rows so updates are efficient and smooth.
I’ve tried:
• Using <Flop.Phoenix.sort_link> inside label={…}, but that doesn’t work because label expects a string.
• Adding slots like <:label>, but <.table> doesn’t support that.
• Using Flop.Phoenix.table, which supports sorting but does not support phx-update=“stream”, so it doesn’t play nicely with the Core Components setup.
⸻
Question:
Has anyone found a clean way to integrate Flop sorting into the Core Components <.table> while still leveraging LiveView streams for the table body—without having to rebuild the table manually?
If you’ve come across a pattern or a component wrapper that does exactly this, I’d love to see it!
Thanks in advance.
Most Liked
woylie
I’m using the Flop table for most use cases throughout all projects I’m working on. I still have a simple_table component in CoreComponents for cases where I don’t need pagination, filtering, or sorting. Both components are interchangeable, with the exception of the required Flop.Meta struct.
woylie
Flop.Phoenix.table supports streams, there’s an example in the readme: LiveView streams. phx-update="stream" is set automatically when a stream is passed to the component. The implementation is very close to the table implementation from CoreComponents.
Popular in Questions
Other popular topics
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
- #forms
- #api
- #metaprogramming
- #security
- #hex









