` y poder añadir clases, normalmente para hacer scroll horizontal en la tabla en anchuras pequeñas. Por accesibilidad, parámetro wrapper necesitará los atributos: tabindex=0, role=section y un aria-label o aria-labelledby.
Mostrar códigodel ejemplo: Tabla con wrapper
#### Contenido
Nunjucks macro HTML
##### Nunjucks macro
```js
{% from "components/table/_macro.table.njk" import componentTable %}
{{ componentTable({
"caption": "Caption 1: Meses y pagos",
"captionClasses": "sticky left-0 top-0 w-0 mb-base font-bold text-left text-lg lg:whitespace-nowrap",
"firstCellIsHeader": true,
"head": [
{
"text": "Mes de pago",
"classes": "lg:whitespace-nowrap"
},
{
"text": "Primer pago",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Segundo pago",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for A",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for B",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for C",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for D",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for E",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for F",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for G",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for H",
"classes": "lg:whitespace-nowrap lg:text-right"
}
],
"rows": [
[
{
"text": "Enero"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
}
],
[
{
"text": "Febrero"
},
{
"text": "75€",
"classes": "lg:text-right"
},
{
"text": "55€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
}
],
[
{
"text": "Marzo"
},
{
"text": "165€",
"classes": "lg:text-right"
},
{
"text": "125€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
}
]
],
"wrapper": {
"classes": "relative overflow-x-auto pb-base focus:outline-hidden focus:shadow-outline-black",
"attributes": {
"tabindex": "0",
"role": "region",
"aria-label": "Tabla con scroll del ejemplo Tabla con wrapper"
}
}
}) }}
```
##### HTML
```html
Caption 1: Meses y pagos
| Mes de pago |
Primer pago |
Segundo pago |
Rate for A |
Rate for B |
Rate for C |
Rate for D |
Rate for E |
Rate for F |
Rate for G |
Rate for H |
| Enero |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
| Febrero |
75€ |
55€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
| Marzo |
165€ |
125€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
```
### Tabla no responsive [#](#tabla-no-responsive)
Usa la clase modificadora `.c-table--no-responsive` junto al parámetro `wrapper` para tablas que usen rowspan o colspan o tablas que no queremos que muestren sus celdas apiladas en móvil.
Mostrar códigodel ejemplo: Tabla no responsive
#### Contenido
Nunjucks macro HTML
##### Nunjucks macro
```js
{% from "components/table/_macro.table.njk" import componentTable %}
{{ componentTable({
"classes": "c-table--no-responsive w-full",
"caption": "Caption 1: Meses y pagos",
"captionClasses": "mb-base font-bold text-left text-lg",
"firstCellIsHeader": true,
"head": [
{
"text": "Mes de pago",
"classes": "lg:whitespace-nowrap"
},
{
"text": "Primer pago",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Segundo pago",
"classes": "lg:whitespace-nowrap lg:text-right"
}
],
"rows": [
[
{
"text": "Enero"
},
{
"text": "85€",
"classes": "text-center",
"rowspan": 2,
"colspan": 2
}
],
[
{
"text": "Febrero"
}
],
[
{
"text": "Marzo"
},
{
"text": "165€",
"classes": "lg:text-right"
},
{
"text": "125€",
"classes": "lg:text-right"
}
]
],
"wrapper": {
"classes": "relative overflow-x-auto pb-base focus:outline-hidden focus:shadow-outline-black",
"attributes": {
"tabindex": "0",
"role": "region",
"aria-label": "Tabla con scroll del ejemplo Tabla no responsive"
}
}
}) }}
```
##### HTML
```html
Caption 1: Meses y pagos
| Mes de pago |
Primer pago |
Segundo pago |
| Enero |
85€ |
| Febrero |
| Marzo |
165€ |
125€ |
```
### Tabla con columnas sticky [#](#tabla-con-columnas-sticky)
En este ejemplo la primera y última columna se mantienen fijas y el resto hacen scroll horizontal si la anchura es pequeña.
Mostrar códigodel ejemplo: Tabla con columnas sticky
#### Contenido
Nunjucks macro HTML
##### Nunjucks macro
```js
{% from "components/table/_macro.table.njk" import componentTable %}
{{ componentTable({
"caption": "Caption 1: Meses y pagos",
"captionClasses": "sticky top-0 left-0 w-0 mb-base font-bold text-left text-lg",
"firstCellIsHeader": true,
"head": [
{
"text": "Mes de pago",
"classes": "lg:whitespace-nowrap sticky left-0 w-60 bg-white"
},
{
"text": "Primer pago",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Segundo pago",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for A",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for B",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for C",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for D",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for E",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for F",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for G",
"classes": "lg:whitespace-nowrap lg:text-right"
},
{
"text": "Rate for H",
"classes": "lg:whitespace-nowrap lg:text-right sticky right-0 w-60 bg-white"
}
],
"rows": [
[
{
"text": "Enero",
"classes": "sticky left-0 w-60 bg-white"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right sticky right-0 w-60 bg-white"
}
],
[
{
"text": "Febrero",
"classes": "sticky left-0 w-60 bg-white"
},
{
"text": "75€",
"classes": "lg:text-right"
},
{
"text": "55€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right sticky right-0 w-60 bg-white"
}
],
[
{
"text": "Marzo",
"classes": "sticky left-0 w-60 bg-white"
},
{
"text": "165€",
"classes": "lg:text-right"
},
{
"text": "125€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right"
},
{
"text": "85€",
"classes": "lg:text-right"
},
{
"text": "95€",
"classes": "lg:text-right sticky right-0 w-60 bg-white"
}
]
],
"wrapper": {
"classes": "overflow-x-auto pb-base focus:outline-hidden focus:shadow-outline-black",
"attributes": {
"tabindex": "0",
"role": "region",
"aria-label": "Tabla con scroll del ejemplo Tabla con columnas sticky"
}
},
"classes": "relative lg:whitespace-nowrap"
}) }}
```
##### HTML
```html
Caption 1: Meses y pagos
| Mes de pago |
Primer pago |
Segundo pago |
Rate for A |
Rate for B |
Rate for C |
Rate for D |
Rate for E |
Rate for F |
Rate for G |
Rate for H |
| Enero |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
| Febrero |
75€ |
55€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
| Marzo |
165€ |
125€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
85€ |
95€ |
```