calebjosue
How do you display an Inline element right next to an input field in Elixir/Phoenix?
Hello there all,
I followed the steps depicted at mix phx.gen.auth — Phoenix v1.8.8 in order to get started with an authentication system.
I would like to achieve the feature of showing a little
icon in the password field as portrayed in the next picture.
The above it’s just plain HTML with CSS (For POC purposes), no Phoenix app in place.
Still, when I try to replicate the above behavior within the aforementioned Phoenix generated code. I don’t get the expected results, instead I am seeing the eye below the password field and it seems to be rotated as well. Have a look.
I’ve placed the following CSS code in the assets/css/app.css file.
.see::before {
margin-left: -25px;
cursor: pointer;
content: "\1F441";
font-weight: bold;
}
The relevant code inside lib/my_app_name_web/live/user_login_live.ex is as follows:
<.input field={@form[:password]} type="password" label="Password" required /><i class="see"></i>
Please note the use of the see class inside the i HTML tag (Which is an inline element), right next to the password field.
So, what do you guys think is happening?
I know this question is heavily related to CSS and not Phoenix per se but I am pretty sure you guys know how to integrate CSS within a Phoenix app effectively.
Thank you very much for your answers in advance.
–
Caleb (https://www.calebjosue.com)
First Post!
coen.bakker
Have you considered using absolute positioning of the icon? And/or using a wrapper around the input tag?
Usually there are many ways of getting things done with CSS.
I personally like to use display grid and flex-box to ensure proper placement of all elements relative to each other. If you don’t want the input text to appear behind the icon, that might be a good option.
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
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









