GazeIntoTheAbyss

GazeIntoTheAbyss

Why are classes like “phx-connected” applied behind the scenes with no references to the CSS properties they have?

Is there a list anywhere that details all the random classes that can be added behind the scenes and under which circumstances? It would be nice to know in advance before wasting time. Just spent about 10 minutes try to figure out why I couldn’t set a width to 100%, only to find out it was being restriced by “phx-connected” which has no CSS properties that I can find.

If I create the phx-connected class and change the width to 100% I can fix my current problem, but what happens later when phx-connected gets added to an object whose width or other properties I don’t want to be the same?

Is phx-connected applied to every socket connection, and if so should I be treating it as my entire pages container to be safe? I also had a phx-class messing with my spacing on a text-area yesterday.

Any info on how I’m meant to deal with this is appreciated.

Edit:

I forgot to add, if they are adding hidden classes, why not set the heights and widths to something like inherit? At least then if someone isn’t aware it exists, it will take the properties of its parent.

Showing Posts 1 to 4

polypush135

polypush135

Have a look at how the binding works.

In short they are just there for convenience so that you can respond to different life cycle states in the UI.

IE: phx-connected may apply a hidden class to some loader spinner, while phx-loading shows it initially. At the end of the day though I don’t think anyone is trying to tell you how to use them, so there’s not a lot of already existing styles for each life cycle state. That parts up to you.

Loading states and errors

All phx- event bindings apply their own css classes when pushed. For example the following markup:

<button phx-click="clicked" phx-window-keydown="key">...</button>

On click, would receive the phx-click-loading class, and on keydown would receive the
phx-keydown-loading class. The css loading classes are maintained until an acknowledgement is received on > the client for the pushed event.

GazeIntoTheAbyss

GazeIntoTheAbyss OP

I’ve seen the JS file in my app so I figured they add classes for multiple things, what I don’t get is the standard way to manage this as you can quite easily do what I’ve done and spend I day working on something then find out its impossible to complete without restructuring everything.

Some of the other things I’ve had to deal with could only be done due to setting position which I didn’t really want to do.

My issue btw was being caused by this:

<body>
    <main class="container">
      <%= @inner_content %>
    </main>
</body>

I figured I could create a general container for all my live views like the above
The issue was that the inspect order was this

  • Container - 100%
  • Phx-Connected - No value
  • Rest of my code - 100% of nothing is nothing

This meant that the containers 100% width just disappears at the phx-connected stage

I’ve now just wrapped all my liveviews with container to change the order to

  • Phx-Connected - No value
  • Container - 100%
  • Rest of my code - 100%

It’s messed a bunch of things up but at least it will hopefully work going forwards.

polypush135

polypush135

I figured I could create a general container for all my live views like the above
The issue was that the inspect order was this

The LV container has a way of adding classes to it directly.

have a look at how LV is defined in your MyAppWeb.ex file.

def live_view do
    quote do
      use Phoenix.LiveView,
        container: {:div, class: "h-full"},
        layout: {MyAppWeb.Layouts, :app}

      unquote(html_helpers())
    end
  end

Is this what you mean?

GazeIntoTheAbyss

GazeIntoTheAbyss OP

I mean because I had @inner_content wrapped in my “container” it was applying the phx-connected class to the @inner_content after I set the containers dimensions. As phx-connected doesn’t seem to have height/width set to anything and is just display block it was messing with all the divs that were visibly children of the “container” to me.

Moving the “container” within the @inner_content fix it because phx-connected becomes the parent of “container” instead of the first child.

Basically @inner_content seems to apply a class of “phx-connected” which only has a “display: block” property meaning you lose all values outside of it in terms of height/width

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews