> ## Documentation Index
> Fetch the complete documentation index at: https://react-docx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PageNumber

Dynamic page number field.

```tsx theme={"dark"}
<Paragraph>
  Page <PageNumber />
</Paragraph>
```

***

## Props

| Prop     | Type                                 | Default     | Description          |
| -------- | ------------------------------------ | ----------- | -------------------- |
| `type`   | `"current"` \| `"total"` \| `"both"` | `"current"` | What to display      |
| `format` | `string`                             | —           | Custom format string |

***

## Types

### Current page

```tsx theme={"dark"}
<PageNumber />
// or
<PageNumber type="current" />
```

Outputs: 1, 2, 3...

### Total pages

```tsx theme={"dark"}
<PageNumber type="total" />
```

Outputs the total page count.

### Both

```tsx theme={"dark"}
<PageNumber type="both" />
```

Outputs: "Page 1 of 10"

***

## Custom format

Use `{current}` and `{total}` placeholders:

```tsx theme={"dark"}
<PageNumber format="{current} / {total}" />
// Output: "1 / 10"

<PageNumber format="- {current} -" />
// Output: "- 1 -"

<PageNumber format="Page {current}" />
// Output: "Page 1"

<PageNumber format="{current} of {total} pages" />
// Output: "1 of 10 pages"
```

***

## Usage

PageNumber is typically used inside headers or footers:

```tsx theme={"dark"}
<Section>
  <Section.Footer>
    <Paragraph className="text-center">
      <PageNumber type="both" />
    </Paragraph>
  </Section.Footer>

  <Paragraph>Content...</Paragraph>
</Section>
```

Can also be used in regular content:

```tsx theme={"dark"}
<Paragraph>
  See page <PageNumber /> for details.
</Paragraph>
```

***

## Common patterns

### Simple footer

```tsx theme={"dark"}
<Section.Footer>
  <Paragraph className="text-center text-xs">
    <PageNumber />
  </Paragraph>
</Section.Footer>
```

### Page X of Y

```tsx theme={"dark"}
<Section.Footer>
  <Paragraph className="text-center text-xs">
    Page <PageNumber /> of <PageNumber type="total" />
  </Paragraph>
</Section.Footer>
```

### With document title

```tsx theme={"dark"}
<Section.Footer>
  <Paragraph className="text-xs">
    Annual Report 2024<Tab /><Tab />Page <PageNumber />
  </Paragraph>
</Section.Footer>
```

### Styled page number

```tsx theme={"dark"}
<Section.Footer>
  <Paragraph className="text-center">
    <Text className="text-gray-400 text-xs">
      Page <PageNumber /> of <PageNumber type="total" />
    </Text>
  </Paragraph>
</Section.Footer>
```

### Right-aligned

```tsx theme={"dark"}
<Section.Footer>
  <Paragraph className="text-right text-xs text-gray-500">
    <PageNumber type="both" />
  </Paragraph>
</Section.Footer>
```
