Some feedback for phoenix live view (from who is getting started)

Some feedback from who is getting started…

  1. The default milligram CSS framework is classless, but not featured. I spent 2 days just trying to switch to bootstrap and make it to work. One example Bootstrap has a great navbar(works great on mobile) and other components. Why not bootstrap by default? If advanced users want to go with another classless framework they will know how to change. Bootstrap has support ARIA by default and all examples include the aria attributes.

  2. it was really confusing the fact that package.json is within assets dir. When trying to make the bootstrap modal to work I did execute yarn add bootstrap jquery popper.js in the root. I could include bootstrap somehow, the styles worked(perhaps because of live dashboard?). Then, I figured that out I need to include in the package.json within the assets dir.

  3. Bootstrap modal was a little bit tricky to keep the fade effect working. I had to ensure the modal was at the DOM and toggle it using phx-hook, it worked. But, now the form fields lost reference somehow and there is no error.

  4. Documentation is great, well written, I am reading it slowly but already trying to code it. If it had the support to bootstrap by default my project was already done. :smiley: Really fast prototyping except by the CSS framework.

Hi @sadjow,

There’s a discussion here on the reasons why… Bootstrap 4 final in next Phoenix release? (Update: No... Phoenix 1.4 uses Milligram)

If you ever need any help on things like this, feel free to ask. I’m using bootstrap 4 in a LV project and it was quite straightforward to get going with a couple of small pointers in how the assets setup works. You’ve obviously figured it out now!

1 Like

Hi @mindok ! :slightly_smiling_face:

So, I generated the code using

In the list of users, that I generated in the admin/ web context. I am trying to render the modal: I did move it out of if @live_action in [:new, :edit] do. Because I wanted to keep the fade effect, show the modal appearing and the modal disappearing. I created the open_modal option based on the boolean. I got it working also without the effect. But, for some reason, the fields/validation are not working anymore and no error is shown.


<%#= if @live_action in [:new, :edit] do %>

<%# end %>

<%= live_modal @socket, FuderosoWeb.Admin.UserLive.FormComponent,
    id: || :new,
    title: @page_title,
    action: @live_action,
    user: @user,
    open_modal: @live_action in [:new, :edit],
    return_to: Routes.admin_user_index_path(@socket, :index) %>

modal_component.ex (changed the generated one)

defmodule FuderosoWeb.ModalComponent do
  use FuderosoWeb, :live_component

  @impl true
  def render(assigns) do
    <div id="<%= @id %>"
      class="modal fade"
      data-show="<%= @opts[:open_modal] %>"
      phx-target="#<%= @id %>"
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-body">
            <%= live_patch to: @return_to, class: "close", "aria-label": "Close" do %>
              <span aria-hidden="true">&times;</span>
            <% end %>
            <%= live_component @socket, @component, @opts %>

    # ~L"""
    # <div id="<%= @id %>" class="phx-modal"
    #   phx-capture-click="close"
    #   phx-window-keydown="close"
    #   phx-key="escape"
    #   phx-target="#<%= @id %>"
    #   phx-page-loading>

    #   <div class="phx-modal-content">
    #     <%= live_patch raw("&times;"), to: @return_to, class: "phx-modal-close" %>
    #     <%= live_component @socket, @component, @opts %>
    #   </div>
    # </div>
    # """

  @impl true
  def handle_event("close", _, socket) do
    {:noreply, push_patch(socket, to: socket.assigns.return_to)}

and in the hooks I was trying something with this:

let Hooks = {};
Hooks.Modal = {
  mounted() {
    if ($(this.el).data("show")) {
    } else {
  updated() {
    if ($(this.el).data("show")) {
    } else {

that hooks object is attached to the live connection

let liveSocket = new LiveSocket("/live", Socket, {
  params: { _csrf_token: csrfToken },
  hooks: Hooks,

of course this is not optimized code. I am just trying it out.

I gave up the modal fade animation. I did mount it only when it is in the action I did add these classes. The form did not lost any reference to the validation, it was needed to add display: block to .invalid-feedback class.

.invalid-feedback {
  display: block;

.modal {
  display: block;
  background-color: change-color(gray, $alpha: 0.5, $lightness: 20%);

BTW, I think for Information Systems, ERP. animations are not good. Let’s keep without them.

1 Like