Pagination

Mostrar parámetros

Parámetros del componente

              params:
- name: id
  type: string
  required: true
  description: The id of the pagination.
- name: hasSelect
  type: boolean
  required: false
  description: If true, the pagination appearance shows a select to select active page instead of a button group.
- name: ariaLabel
  type: string
  required: true
  description: String to add an aria-label to the nav.
- name: classesContainer
  type: string
  required: false
  description: Classes to add to the container div.
- name: totalItems
  type: string
  required: true
  description: Total number of items.
- name: itemsPerPage
  type: string
  required: true
  description: Number of items per each page.
- name: showPrevious
  type: boolean
  required: false
  description: If true, shows the Previous button if hasSelect is true. Defaults to true.
- name: hasPrevious
  type: boolean
  required: false
  description: If false, the Previous button is disabled. Defaults to true.
- name: previousText
  type: string
  required: false
  description: Text for the previous button. Defaults to "Anterior".
- name: showNext
  type: boolean
  required: false
  description: If true, shows the Next button if hasSelect is true. Defaults to true.
- name: hasNext
  type: boolean
  required: false
  description: If false, the Next button is disabled. Defaults to true.
- name: nextText
  type: string
  required: false
  description: Text for the previous button. Defaults to "Siguiente".
- name: showFirst
  type: boolean
  required: false
  description: If true, shows the First button if hasSelect is true. Defaults to false.
- name: hasFirst
  type: boolean
  required: false
  description: If false, the First button is disabled. Defaults to true.
- name: firstText
  type: string
  required: false
  description: Text for the first button. Defaults to "Primera".
- name: showLast
  type: boolean
  required: false
  description: If true, shows the Last button if hasSelect is true. Defaults to false.
- name: hasLast
  type: boolean
  required: false
  description: If false, the Last button is disabled. Defaults to true.
- name: lastText
  type: string
  required: false
  description: Text for the last button. Defaults to "Última".
- name: itemsListbox
  type: object
  required: false
  description: Options for a listbox component to choose number of items per page.
  - name: label
    type: object
    required: true
    description: Label text or HTML by specifying value for either text or html keys.
    - name: text
      type: string
      required: true
      description: If `html` is set, this is not required. Text for the button. If `html` is provided, the `text` argument will be ignored.
    - name: html
      type: string
      required: true
      description: If `text` is set, this is not required. HTML for the button. If `html` is provided, the `text` argument will be ignored.
    - name: classes
      type: string
      required: false
      description: Classes to add to the element that acts as label.
  - name: items
    type: array
    required: true
    description: Array of items objects.
    params:
    - name: text
      type: string
      required: true
      description: If `html` is set, this is not required. Text to use within each item. If `html` is provided, the `text` argument will be ignored.
    - name: html
      type: string
      required: true
      description: If `text` is set, this is not required. HTML to use within each item. If `html` is provided, the `text` argument will be ignored.
    - name: id
      type: string
      required: false
      description: Specific id attribute for the item. If omitted, then idPrefix option will be applied.
    - name: active
      type: boolean
      required: false
      description: If true, item will be active.
    - name: classes
      type: string
      required: false
      description: Classes to add to the item.
    - name: attributes
      type: object
      required: false
      description: HTML attributes (for example data attributes) to add to the item.
- name: items
  type: array
  required: true
  description: Array of items objects.
  params:
  - name: href
    type: string
    required: true
    description: Item link.
  - name: active
    type: boolean
    required: false
    description: If true, item will be active.
  - name: classes
    type: string
    required: false
    description: Classes to add to the item.
  - name: attributes
    type: object
    required: false
    description: HTML attributes (for example data attributes) to add to the item.
- name: classes
  type: string
  required: false
  description: Classes to add to the pagination nav container tag.
- name: attributes
  type: object
  required: false
  description: HTML attributes (for example data attributes) to add to the pagination nav container tag.
              
            

Por defecto

Mostrar códigodel ejemplo: Por defecto

Contenido

Nunjucks macro

{% from "components/pagination/_macro.pagination.njk" import componentPagination %}

{{ componentPagination({
  "id": "default",
  "idPrefix": "pagination",
  "totalItems": "64",
  "itemsPerPage": "10",
  "items": [
    {
      "href": "#",
      "text": 1
    },
    {
      "href": "#",
      "text": 2,
      "active": true
    },
    {
      "href": "#",
      "text": 3
    },
    {
      "href": "#",
      "text": 4
    },
    {
      "href": "#",
      "text": 5
    },
    {
      "href": "#",
      "text": 6
    }
  ],
  "attributes": {
    "aria-label": "Paginación"
  }
}) }}

Estilo listbox

Usa el parámetro "hasSelect": true para mostrar la paginación como un Listbox en vez de botones.

Selecciona una página para cargar datos

Posición de paginación: 10 - 20 de 64

Mostrar códigodel ejemplo: Estilo listbox

Contenido

Nunjucks macro

{% from "components/pagination/_macro.pagination.njk" import componentPagination %}

{{ componentPagination({
  "id": "listbox-style",
  "hasSelect": true,
  "idPrefix": "pagination-has-select",
  "totalItems": "64",
  "itemsPerPage": "10",
  "items": [
    {
      "href": "#",
      "text": 1
    },
    {
      "href": "#",
      "text": 2,
      "active": true
    },
    {
      "href": "#",
      "text": 3
    },
    {
      "href": "#",
      "text": 4
    },
    {
      "href": "#",
      "text": 5
    },
    {
      "href": "#",
      "text": 6
    },
    {
      "href": "#",
      "text": 7
    },
    {
      "href": "#",
      "text": 8
    },
    {
      "href": "#",
      "text": 9
    },
    {
      "href": "#",
      "text": 10
    },
    {
      "href": "#",
      "text": 11
    },
    {
      "href": "#",
      "text": 12
    },
    {
      "href": "#",
      "text": 13
    },
    {
      "href": "#",
      "text": 14
    }
  ],
  "previousText": "Anterior",
  "nextText": "Siguiente",
  "attributes": {
    "aria-label": "Paginación"
  }
}) }}

Con página previa deshabilitada

En este ejemplo "hasSelect": true y "hasPrevious": false

Selecciona una página para cargar datos

Posición de paginación: 0 - 10 de 64

Mostrar códigodel ejemplo: Con página previa deshabilitada

Contenido

Nunjucks macro

{% from "components/pagination/_macro.pagination.njk" import componentPagination %}

{{ componentPagination({
  "id": "with-previous-page-disabled",
  "hasSelect": true,
  "idPrefix": "pagination-without-prev",
  "totalItems": "64",
  "itemsPerPage": "10",
  "items": [
    {
      "href": "#",
      "text": 1,
      "active": true
    },
    {
      "href": "#",
      "text": 2
    },
    {
      "href": "#",
      "text": 3
    },
    {
      "href": "#",
      "text": 4
    },
    {
      "href": "#",
      "text": 5
    },
    {
      "href": "#",
      "text": 6
    }
  ],
  "hasPrevious": false,
  "previousText": "Anterior",
  "nextText": "Siguiente",
  "attributes": {
    "aria-label": "Paginación"
  }
}) }}

Sin página previa

En este ejemplo "hasSelect": true y "showPrevious": false

Selecciona una página para cargar datos

Posición de paginación: 0 - 10 de 64

Mostrar códigodel ejemplo: Sin página previa

Contenido

Nunjucks macro

{% from "components/pagination/_macro.pagination.njk" import componentPagination %}

{{ componentPagination({
  "id": "without-previous-page",
  "hasSelect": true,
  "idPrefix": "pagination-without-prev",
  "totalItems": "64",
  "itemsPerPage": "10",
  "items": [
    {
      "href": "#",
      "text": 1,
      "active": true
    },
    {
      "href": "#",
      "text": 2
    },
    {
      "href": "#",
      "text": 3
    },
    {
      "href": "#",
      "text": 4
    },
    {
      "href": "#",
      "text": 5
    },
    {
      "href": "#",
      "text": 6
    }
  ],
  "showPrevious": false,
  "previousText": "Anterior",
  "nextText": "Siguiente",
  "attributes": {
    "aria-label": "Paginación"
  }
}) }}

Con página primera y última

En este ejemplo "hasSelect": true, "showFirst": true y "showLast": true

Mostrar códigodel ejemplo: Con página primera y última

Contenido

Nunjucks macro

{% from "components/pagination/_macro.pagination.njk" import componentPagination %}

{{ componentPagination({
  "id": "without-previous-page-disabled",
  "hasSelect": true,
  "idPrefix": "pagination-without-prev",
  "totalItems": "64",
  "itemsPerPage": "10",
  "items": [
    {
      "href": "#",
      "text": 1
    },
    {
      "href": "#",
      "text": 2,
      "active": true
    },
    {
      "href": "#",
      "text": 3
    },
    {
      "href": "#",
      "text": 4
    },
    {
      "href": "#",
      "text": 5
    },
    {
      "href": "#",
      "text": 6
    }
  ],
  "previousText": "Anterior",
  "nextText": "Siguiente",
  "showFirst": true,
  "showLast": true,
  "firstText": "Primera",
  "lastText": "Última",
  "attributes": {
    "aria-label": "Paginación"
  }
}) }}

Con página primera deshabilitada y última

En este ejemplo "hasSelect": true, "hasPrevious": false, "showFirst": true y "hasFirst": false

Selecciona una página para cargar datos

Posición de paginación: 0 - 10 de 64

Mostrar códigodel ejemplo: Con página primera deshabilitada y última

Contenido

Nunjucks macro

{% from "components/pagination/_macro.pagination.njk" import componentPagination %}

{{ componentPagination({
  "id": "listbox-style",
  "hasSelect": true,
  "idPrefix": "pagination-has-select",
  "totalItems": "64",
  "itemsPerPage": "10",
  "items": [
    {
      "href": "#",
      "text": 1,
      "active": true
    },
    {
      "href": "#",
      "text": 2
    },
    {
      "href": "#",
      "text": 3
    },
    {
      "href": "#",
      "text": 4
    },
    {
      "href": "#",
      "text": 5
    },
    {
      "href": "#",
      "text": 6
    },
    {
      "href": "#",
      "text": 7
    },
    {
      "href": "#",
      "text": 8
    },
    {
      "href": "#",
      "text": 9
    },
    {
      "href": "#",
      "text": 10
    },
    {
      "href": "#",
      "text": 11
    },
    {
      "href": "#",
      "text": 12
    },
    {
      "href": "#",
      "text": 13
    },
    {
      "href": "#",
      "text": 14
    }
  ],
  "hasPrevious": false,
  "previousText": "Anterior",
  "nextText": "Siguiente",
  "showFirst": true,
  "showLast": true,
  "hasFirst": false,
  "firstText": "Primera",
  "lastText": "Última",
  "attributes": {
    "aria-label": "Paginación"
  }
}) }}

Con itemslistbox

Usa el parámetro itemsListbox para mostrar un listbox que permite elegir el ´numero de items por página, a la derecha.

Selecciona una página para cargar datos

Items por página:

  • 10
  • 25
  • 50
  • 75
  • 100

Posición de paginación: 10 - 20 de 64

Mostrar códigodel ejemplo: Con itemslistbox

Contenido

Nunjucks macro

{% from "components/pagination/_macro.pagination.njk" import componentPagination %}

{{ componentPagination({
  "id": "with-items-listbox",
  "idPrefix": "with-items-listbox",
  "totalItems": "64",
  "itemsPerPage": "10",
  "hasSelect": true,
  "itemsListbox": {
    "items": [
      {
        "text": "10",
        "active": true
      },
      {
        "text": "25"
      },
      {
        "text": "50"
      },
      {
        "text": "75"
      },
      {
        "text": "100"
      }
    ]
  },
  "items": [
    {
      "href": "#",
      "text": 1
    },
    {
      "href": "#",
      "text": 2,
      "active": true
    },
    {
      "href": "#",
      "text": 3
    },
    {
      "href": "#",
      "text": 4
    },
    {
      "href": "#",
      "text": 5
    },
    {
      "href": "#",
      "text": 6
    }
  ],
  "hasPrevious": false,
  "hasNext": true,
  "previousText": "Anterior",
  "nextText": "Siguiente",
  "attributes": {
    "aria-label": "Paginación"
  }
}) }}