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

151
Vistas
Delete long text in TagInput

I have TagsInput where the user can enter any data (assumed to be links). Since links can be very long, I need a way to shorten their display so that the window does not stretch too much. I solved it with white-space: nowrap

Since I'm using TagsInput, the user should be able to delete the input. I have this functionality. And as you can see, it works on short links. But if the link is long, this cross is at the end and, accordingly, it is not visible. I would like everything to be displayed as follows (I marked the desired functionality in red):

Thus, I want the user to be able to delete a long link

.tag {
    display:flexbox;
    /* align-items: center; */
    margin: 5px 0;
    margin-right: 5px;
    padding: 0 5px;
    border: 1px solid black;
    border-radius: 5px;
    color: black;
    overflow:hidden;
    text-overflow: ellipsis;
    max-width: fit-content;
    white-space: nowrap;
}

Just in case, the part of the code where I define the button to remove the tag

...
    const deleteTag = (index) => {
    setTags(prevState => prevState.filter((tag, i) => i !== index))
}

return (
    <div className={classes.container}>
        {tags.map((tag, index) => <div className={classes.tag}>
            {tag}
            <ClearIcon className={classes.del} fontSize="small" onClick={() => deleteTag(index)} />
        </div>
        )}
        <input
            className={classes.input}
            value={input}
            placeholder={props.inputPlaceholder}
            onKeyDown={onKeyDown}
            onKeyUp={onKeyUp}
            onChange={onChange}
        />
    </div>);
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you try to make it simple then you need to restructure your JSX:

<div className="tag">
  <div className="tag-name">www.google.com/dummytext/123</div>
  <ClearIcon className={classes.del} fontSize="small" onClick={() =>deleteTag(index)} />
</div>

CSS:

.tag {
  display: flex;
  border: 1px solid black;
  border-radius: 5px;
  padding: 0 5px;
  max-width: fit-content;
  margin: 5px 0;
}

.tag-name {
  margin-right: 5px;
  color: black;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: -moz-fit-content;
  max-width: fit-content;
  white-space: nowrap;
}
about 4 years ago · Juan Pablo Isaza 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