Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

287
Vistas
How can I make an icon inside of a bootstrap 5 form-floating label clickable?

I'd like to have a clickable icon as part of a form-floating label but the label seems to be rendered behind the input.

I tried playing with z-index without any luck and I'm not sure what else I can do to fix the problem. Could someone point me in the right direction?

https://blazorfiddle.com/s/y4143uso

Screenshot of the example cols from the fiddle

The "Test" button and icon on its own (col#3, col#4) work, but the first two col's with form-floating examples won't redirect when the icon is clicked.

@page "/"
@inject NavigationManager NavigationManager

<div class="container-fluid">
    <div class="row">
        <div class="col-1">
            <div class="form-floating">
                <input type="text" class="form-control" placeholder="bla">
                <label>LABEL<i class="fas fa-info-circle ps-1" @onclick="Test"></i></label>
            </div>
        </div>
        <div class="col-1">
            <div class="form-floating">
                <input type="text" class="form-control" value="blabla">
                <label>LABEL<i class="fas fa-info-circle ps-1" @onclick="Test"></i></label>
            </div>
        </div>
        <div class="col-1">
            <button type="button" class="btn btn-sm btn-primary" @onclick="Test">Test</button>
        </div>
        <div class="col-1">
            <i class="fas fa-info-circle ps-1" @onclick="Test"></i>
        </div>
    </div>
</div>
@code {
    void Test()
    {
        NavigationManager.NavigateTo("https://google.com");
    }
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You have to handle pointer-events belong to child labels. If a click event does not occur, firstly you should think about pointer-events.

.clickable-icon{
    pointer-events: auto !important; // required
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<div class="container my-2">
    <div class="form-floating">
  <input type="text" class="form-control" id="floatingInput" placeholder="Click Icons" value="Click Icons">
  <label for="floatingInput">Clickable Icon <label class="clickable-icon" onclick="alert('hello')">&#128512;</label> <label class="clickable-icon ms-1" onclick="alert('clicked')">&#x26A1;</label></label>
</div>
</div>

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda