Descripción general del área de texto de Web Components
The Ignite UI for Web Components Text Area represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizable amount of free-form text, for example a comment on a review or feedback form.
<!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
There are three different resize options of the IgcTextareaComponent. When set to none, the text area does not resize and uses a scroll bar to show overflow text. When set to vertical (the default option), the text area lets the user resize it vertically. When set to auto, the text area shows all the user input at once. Overflow text wraps onto a new line and expands the text area automatically.
<!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
<!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