Pagination
import { TgPaginationComponent, TgPaginationItemTemplateDirective } from '@trademe/tangram';
Pagination show our users how many pages of content are available, and provides a way to step or navigate through them.
Example
Accessibility
- Pagination is wrapped in a
element so assistive technologies are able to identify it as a navigation section.nav - Pagination automatically provides ARIA labels for all page links rendered.
Behaviour
- Pagination does not wrap when the component exceeds the width of its container.
- The value of
oritemsToShow can be set to change at different breakpoints to avoid pagination visually breaking.compact rounds the number up to the nearest odd number to account for the “current” link, which aims to render in the centre of the pagination control.itemsToShow- The
template directive provides three variables:*tgPaginationItem- Label: The visible label for a page item. For example “Next”, “1”, “2”, “3”.
- Page: The page number used to bind a router link or href.
- Kind: Available values are “first”, “last”, “prev”, “next”, “current” or “page”. Can be used to customise the links as they are rendered.
- The template provided in the code snippet is an
with aa directive applied. Custom HTML can be generated where needed.routerLink - To preserve layout, the “next” and “previous” controls have
set toflex-basis . If the controls are customised, the76px value may need to be updated.flex-basis - Pagination will not show when
istotalPages .0