Skip to main content

What are you looking for?

Try searching for…

Components

Pagination

Pagination is a list of buttons used to navigate between different pages of content, such as search results or tables.

HTML

Press Enter to start editing
Unable to parse html
const PreviewEn = () => {
  return (
    <Pagination aria-label='Pagination menu'>
      <Pagination.List>
        <Pagination.Item>
          <Pagination.Button aria-label='Previous page' data-variant='tertiary'>
            Previous
          </Pagination.Button>
        </Pagination.Item>

        <Pagination.Item>
          <Pagination.Button aria-label='Page 1' data-variant='tertiary'>
            1
          </Pagination.Button>
        </Pagination.Item>

        <Pagination.Item>
          <Pagination.Button aria-label='Page 2' data-variant='primary'>
            2
          </Pagination.Button>
        </Pagination.Item>

        <Pagination.Item />

        <Pagination.Item>
          <Pagination.Button aria-label='Page 9' data-variant='tertiary'>
            9
          </Pagination.Button>
        </Pagination.Item>

        <Pagination.Item>
          <Pagination.Button aria-label='Page 10' data-variant='tertiary'>
            10
          </Pagination.Button>
        </Pagination.Item>

        <Pagination.Item>
          <Pagination.Button aria-label='Next page' data-variant='tertiary'>
            Next
          </Pagination.Button>
        </Pagination.Item>
      </Pagination.List>
    </Pagination>
  );
};

render(<PreviewEn />)

Usage

Add the class name ds-pagination to the <ds-pagination> element. The web component automatically fills the buttons or anchors based on the data attributes data-current and data-total.

If you wish to use your own buttons, you can add <a> or <button> elements inside <ds-pagination>. If you fill these with text and do not pass any attributes, the web component will not change the buttons.

You can use pagination with links (anchor tags).

CSS variables and data attributes

Sizes are controlled with data-size and colors with data-color. The component will inherit from the closest parent where these are set.

CSS Variables
NameValue
--dsc-pagination-gapvar(--ds-size-2)
--dsc-pagination-icon-sizevar(--ds-size-6)
--dsc-pagination-icon-urlurl("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath d='M9.47 5.97a.75.75 0 0 1 1.06 0l5.5 5.5a.75.75 0 0 1 0 1.06l-5.5 5.5a.75.75 0 1 1-1.06-1.06L14.44 12 9.47 7.03a.75.75 0 0 1 0-1.06'/%3E%3C/svg%3E")
--dsc-pagination-ellipsis"\2026"
--dsc-pagination-label"Bla i sider"
--dsc-button-background--activevar(--ds-color-base-active)
--dsc-button-background--hovervar(--ds-color-base-hover)
--dsc-button-backgroundvar(--ds-color-base-default)
--dsc-button-colorvar(--ds-color-base-contrast-default)

No relevant data attributes found.

React

Pagination is a stateless component, and you must control which pages are displayed.

Use usePagination for pagination logic together with the single-part components. Read more about usePagination.

aria-label
Description

Sets the screen reader label for the Pagination area

Type
string
Default
'Bla i sider'
data-current
Description

Current page number

Type
string
data-total
Description

Total number of pages

Type
string
asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior. @deprecated This is not supported anymore, as the element needs to be `ds-pagination`

Type
boolean
Default
false
NameTypeDefaultDescription
aria-labelstring'Bla i sider'

Sets the screen reader label for the Pagination area

data-currentstring-

Current page number

data-totalstring-

Total number of pages

asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior. @deprecated This is not supported anymore, as the element needs to be `ds-pagination`

PaginationButton

aria-current
Description

Toggle button as active Indicates the element that represents the current item within a container or set of related elements.

Type
boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time"
Default
false
command
Description

Native invoker commands. Specifies actions to perform on an element specified by commandfor. Polyfilled by designsystemet-web and includes a custom --show-non-modal command. "show-modal", "close", "request-close", "show-popover", "hide-popover", "toggle-popover", "--show-non-modal"

Type
string
commandfor
Description

Specifies the target element for "command". value is ID of target

Type
string
commandFor
Type
string
type
Description

Specify the type of button. Unset when `asChild` is true

Type
"submit" | "reset" | "button"
Default
'button'
variant
Description

Specify which variant to use

Type
"primary" | "secondary" | "tertiary"
Default
'primary'
asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior.

Type
boolean
Default
false
NameTypeDefaultDescription
aria-currentboolean | "false" | "true" | "page" | "step" | "location" | "date" | "time"false

Toggle button as active Indicates the element that represents the current item within a container or set of related elements.

commandstring-

Native invoker commands. Specifies actions to perform on an element specified by commandfor. Polyfilled by designsystemet-web and includes a custom --show-non-modal command. "show-modal", "close", "request-close", "show-popover", "hide-popover", "toggle-popover", "--show-non-modal"

commandforstring-

Specifies the target element for "command". value is ID of target

commandForstring-

-

type"submit" | "reset" | "button"'button'

Specify the type of button. Unset when `asChild` is true

variant"primary" | "secondary" | "tertiary"'primary'

Specify which variant to use

asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior.

PaginationItem

asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior.

Type
boolean
Default
false
NameTypeDefaultDescription
asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior.

PaginationList

asChild
Description

Change the default rendered element for the one passed as a child, merging their props and behavior.

Type
boolean
Default
false
NameTypeDefaultDescription
asChildbooleanfalse

Change the default rendered element for the one passed as a child, merging their props and behavior.

Below you see usePagination used with pagination to create pagination with links.

You use asChild to change Pagination.Button to <a>.

Edit this page on github.com (opens in a new tab)