Descripción general del área de texto de Web Components
El área de texto Ignite UI for Web Components representa un control de edición de texto sin formato de varias líneas, útil cuando se desea permitir que los usuarios escriban una cantidad considerable de texto de forma libre, por ejemplo, un comentario en un formulario de revisión o comentarios.
<!DOCTYPE html><html><head><title>Textarea Overview</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" /><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v5.css"type="text/css" /></head><body><divid="root"><divclass="container sample center"><igc-textarearows="3"label="Tell us your story:">It was a dark and stormy night...</igc-textarea></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
¿Te gusta esta muestra? Obtenga acceso a nuestro kit de herramientas de Ignite UI for Web Components completo y comience a crear sus propias aplicaciones en minutos. Descárgalo gratis.
dependencias
Para empezar a utilizar el componente Área de texto, primero debe registrar su módulo.
Para comenzar, necesitamos importar el IgcTextareaComponent en nuestro archivo de typescript y registrar el componente llamando a la función defineComponents() de la siguiente manera:
Para obtener una introducción completa a Ignite UI for Web Components, lea el tema Primeros pasos.
Después de importar el IgcTextareaComponent componente, estamos listos para comenzar a usarlo, así que agreguemos nuestra primera área de texto.
<igc-textarearows="5"label="Tell us your story:">It was a dark and stormy night...</igc-textarea>html
Prefijo, sufijo y texto auxiliar
Con prefix las ranuras y suffix podemos añadir diferentes contenidos antes y después del contenido principal del Área de Texto. La helper-text ranura proporciona una pista colocada debajo del área de texto. En el siguiente ejemplo, crearemos un nuevo campo Área de texto con un prefijo de texto, un sufijo de icono y un texto auxiliar como sugerencia:
<!DOCTYPE html><html><head><title>Textarea Slots</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" /><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v5.css"type="text/css" /></head><body><divid="root"><divclass="container sample center"><igc-textarealabel="Your feedback"><igc-iconname="feedback"slot="prefix"aria-hidden="true"></igc-icon><pslot="helper-text">Give us a short description of what you liked/disliked</p></igc-textarea></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Cambio de tamaño del área de texto
Hay tres opciones diferentes de cambio de tamaño. IgcTextareaComponent Cuando se establece en none, el área de texto no cambia de tamaño y utiliza una barra de desplazamiento para mostrar el texto desbordado. Cuando se establece en vertical (la opción predeterminada), el área de texto permite al usuario cambiar su tamaño verticalmente. Cuando se establece en auto, el área de texto muestra todas las entradas del usuario a la vez. El texto de desbordamiento se ajusta a una nueva línea y expande el área de texto automáticamente.
<!DOCTYPE html><html><head><title>Textarea Resize</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" /><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v5.css"type="text/css" /></head><body><divid="root"><divclass="container sample center"><igc-textarealabel="Resize: none"resize="none"><pslot="helper-text">This textarea does not resize and uses a scroll bar to show overflow text.</p></igc-textarea><igc-textarealabel="Resize: vertical (default)"><pslot="helper-text">This textarea lets the user resize vertically.</p></igc-textarea><igc-textarealabel="Resize: auto"resize="auto"><pslot="helper-text">This textarea shows all the user input at once. Overflow text wraps onto a new line and expands the text area.</p></igc-textarea></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
La lista completa de atributos del área de texto se puede encontrar en IgcTextareaComponent API.
Integración de formularios
En el ejemplo siguiente se muestra cómo se podría integrar a IgcTextareaComponent en un formulario.
<!DOCTYPE html><html><head><title>Textarea Form Integration</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" /><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v5.css"type="text/css" /></head><body><divid="root"><divclass="container sample center"><formid="form"><igc-textarearows="3"name="user_feedback"label="Your review"required></igc-textarea><divclass="controls"><igc-buttontype="submit">Submit review</igc-button><igc-buttontype="reset"variant="outlined">Reset</igc-button></div><igc-toastid="submitted"position="top"display-time="1e3">Your review was submitted</igc-toast></form></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
El IgcTextareaComponent componente expone partes CSS para casi todos sus elementos internos. En la tabla siguiente se enumeran todas las partes CSS expuestas:
Nombre
Descripción
container
El contenedor principal que contiene todos los elementos de entrada principales.
<!DOCTYPE html><html><head><title>Textarea Styling</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" /><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v5.css"type="text/css" /></head><body><divid="root"><divclass="container sample center"><igc-textarealabel="Steps to reproduce"><igc-iconname="feedback"slot="prefix"aria-hidden="true"></igc-icon><pslot="helper-text">Provide a detailed description of the steps that led to the issue you experienced</p></igc-textarea></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %>
<scriptsrc="src/index.ts"></script>
<% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css