calebjosue

calebjosue

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 :eye: 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)

Showing Posts 1 to 3

coen.bakker

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.

codeanpeace

codeanpeace

The default display value for an <input> is inline-block which allows elements to its left and right, but the <.input> function component from core_components.ex sets the display value to block which forces a line break.

Default style sheet for HTML 4:
input, select { display: inline-block }

# core_components.ex
  # All other inputs text, datetime-local, url, password, etc. are handled here...
  def input(assigns) do
    ~H"""
    <div phx-feedback-for={@name}>
      <.label for={@id}><%= @label %></.label>
      <input
        ...
        class={[
          "block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6",
           ...
calebjosue

calebjosue OP

People!

Yeah, I ended using the approach mentioned by both of you fellows.

@coen.bakker, wrapping around the input tag, absolute positioning, did it for me. And of course documenting myself about what @codeanpeace said in the process.

Thank you very much, I really appreciate it.


Caleb

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
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
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
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
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews