DESY

Sistema de Diseño del Gobierno de Aragón.

Área de texto

El área de texto es un elemento de formulario que permite la inserción de texto en varias líneas y puede contener, por defecto, un número de caracteres ilimitado.

Textarea

Mostrar parámetros

Parámetros del componente

              params:
- name: id
  type: string
  required: true
  description: The id of the textarea.
- name: name
  type: string
  required: true
  description: The name of the textarea, which is submitted with the form data.
- name: rows
  type: string
  required: false
  description: Optional number of textarea rows (default is 5 rows).
- name: value
  type: string
  required: false
  description: Optional initial value of the textarea.
- name: describedBy
  type: string
  required: false
  description: One or more element IDs to add to the `aria-describedby` attribute, used to provide additional descriptive information for screenreader users.
- name: label
  type: object
  required: true
  description: Options for the label component.
  isComponent: true
- name: hint
  type: object
  required: false
  description: Options for the hint component.
  isComponent: true
- name: errorMessage
  type: object
  required: false
  description: Options for the error message component. The error message component will not display if you use a falsy value for `errorMessage`, for example `false` or `null`.
  isComponent: true
- name: formGroup
  type: object
  required: false
  description: Options for the form-group wrapper
  params:
  - name: classes
    type: string
    required: false
    description: Classes to add to the form group (e.g. to show error state for the whole group)
- name: classes
  type: string
  required: false
  description: Classes to add to the textarea.
- name: autocomplete
  type: string
  required: false
  description: Attribute to [identify input purpose](https://www.w3.org/WAI/WCAG21/Understanding/identify-input-purpose.html), for instance "postal-code" or "username". See [autofill](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill) for full list of attributes that can be used.
- name: placeholder
  type: string
  required: false
  description: Placeholder text
- name: disabled
  type: boolean
  required: false
  description: If true, textarea will be disabled.
- name: attributes
  type: object
  required: false
  description: HTML attributes (for example data attributes) to add to the textarea.
              
            

Por defecto

Esto es una pista o texto descriptivo.

Mostrar códigodel ejemplo: Por defecto

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "name": "more-detail-a",
  "id": "more-detail-a",
  "label": {
    "text": "Esto es un label"
  },
  "hint": {
    "text": "Esto es una pista o texto descriptivo."
  }
}) }}

Deshabilitado

Esto es una pista o texto descriptivo.

Mostrar códigodel ejemplo: Deshabilitado

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "name": "more-detail-b",
  "id": "more-detail-b",
  "disabled": true,
  "label": {
    "text": "Esto es un label"
  },
  "hint": {
    "text": "Esto es una pista o texto descriptivo."
  }
}) }}

Con mensaje de error

Error:Error: esto es un mensaje de error

Mostrar códigodel ejemplo: Con mensaje de error

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "name": "no-ni-reason",
  "id": "no-ni-reason",
  "label": {
    "text": "Esto es un label"
  },
  "errorMessage": {
    "text": "Error: esto es un mensaje de error"
  }
}) }}

Con valor por defecto

Mostrar códigodel ejemplo: Con valor por defecto

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "id": "full-address-a",
  "name": "address-a",
  "value": "Calle Rosales 25. 2 izda",
  "label": {
    "text": "Dirección completa"
  }
}) }}

Con número de filas (rows) personalizada

Mostrar códigodel ejemplo: Con número de filas (rows) personalizada

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "id": "full-address-b",
  "name": "address-b",
  "label": {
    "text": "Dirección completa"
  },
  "rows": 8
}) }}

Con label como encabezado

Utiliza el parámetro "isPageheading": true para que el label esté dentro de un encabezado. Usa el parámetro "headingLevel" para establecer el nivel del encabezado. Por ejemplo: "headingLevel": 3 creará un encabezado <h3>.

Mostrar códigodel ejemplo: Con label como encabezado

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "id": "textarea-with-page-heading-a",
  "name": "address",
  "label": {
    "text": "Esto es un label dentro de un encabezado <h1>",
    "isPageHeading": true
  }
}) }}

Con clases de form-group opcionales

Mostrar códigodel ejemplo: Con clases de form-group opcionales

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "id": "textarea-with-page-heading-b",
  "name": "address",
  "label": {
    "text": "Dirección completa"
  },
  "formGroup": {
    "classes": "p-base bg-primary-light"
  }
}) }}

Con valores de autocompletado

Mostrar códigodel ejemplo: Con valores de autocompletado

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "id": "textarea-with-autocomplete-attribute",
  "name": "address",
  "label": {
    "text": "Dirección completa"
  },
  "autocomplete": "street-address"
}) }}

Placeholder

Mostrar códigodel ejemplo: Placeholder

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "id": "placeholder",
  "name": "placeholder",
  "label": {
    "text": "Valor"
  },
  "placeholder": "Esto es un placeholder"
}) }}

Con clases de css aplicadas

Label inline + Textarea flexible y Mensaje de error

Error:Error: Esto es un mensaje de error

Mostrar códigodel ejemplo: Con clases de css aplicadas

Contenido

Nunjucks macro

{% from "components/textarea/_macro.textarea.njk" import componentTextarea %}

{{ componentTextarea({
  "formGroup": {
    "classes": "lg:flex lg:flex-wrap lg:items-start lg:gap-x-base"
  },
  "label": {
    "text": "Label inline:",
    "classes": "lg:py-sm lg:mt-sm"
  },
  "id": "classes-applied-b",
  "name": "classes-applied-b",
  "errorMessage": {
    "text": "Error: Esto es un mensaje de error",
    "classes": "order-1 w-full pt-sm"
  },
  "classes": "lg:flex-1"
}) }}