> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Spacing tokens

> The seven-step spacing scale Primer Checkout components use for padding and gaps in React Native.

> [!WARNING]
>
> Primer Checkout React Native SDK is currently in **beta** (v3.0.0-beta.1).
> The API is subject to change before the stable release.

`PrimerSpacingTokens` is the spacing scale Primer's components use for padding and the gaps between elements. You override it per mode in the [`theme`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/primer-theme-override) prop of `PrimerCheckoutProvider`, under `light.spacing` and `dark.spacing`. Both take `Partial<PrimerSpacingTokens>`, so you set only the steps you want to change.

```tsx theme={"dark"}
interface PrimerSpacingTokens {
  xxsmall: number;
  xsmall: number;
  small: number;
  medium: number;
  large: number;
  xlarge: number;
  xxlarge: number;
}
```

Values are numbers in React Native layout units. The defaults are the same in light and dark mode.

## Tokens

| Token | Default | Description |
| - | - | - |
| `xxsmall` | 2 | Padding of the header actions in the sheet, such as Back and Cancel. |
| `xsmall` | 4 | Gap between an input's label, field and error message. Also the gap between a status screen's title and subtitle. |
| `small` | 8 | Gaps between closely related elements, such as the parts of a status screen message and the buttons on the error screen. Also the padding inside payment method rows. |
| `medium` | 12 | Inner padding of input fields and buttons, and the gap between sections of the card screen in the sheet. Also sets the input field height. |
| `large` | 16 | Horizontal padding of the sheet header and of the card screen in the sheet. Also the horizontal and top padding of the buttons area on a status screen. |
| `xlarge` | 20 | Vertical padding around a status screen's message. |
| `xxlarge` | 24 | Minimum height of the sheet's header bar. |

## Input field height

An input field's minimum height is `2 × spacing.medium + typography.bodyLarge.lineHeight`, and never less than 44. At the defaults it is 44. With `medium: 16` it is 52, and with `medium: 8` it stays 44.

The border is drawn inside the field, so a thicker border reduces the padding instead of adding height. To set the height of one input, use the `fieldHeight` key of its [`PrimerTextInputTheme`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-inputs). That value is used as given, without the 44 minimum.

Buttons and payment method rows keep a minimum height of 44, whatever the spacing.

## Override spacing

Spacing steps form a scale. Change neighboring steps together to keep the rhythm even. Share one object between both modes:

```tsx theme={"dark"}
import type { PrimerThemeOverride } from '@primer-io/react-native';

const spacing = { small: 12, medium: 16, large: 20 };

const theme: PrimerThemeOverride = {
  light: { spacing },
  dark: { spacing },
};
```

Pass `theme` to `PrimerCheckoutProvider`. These tokens set the spacing inside Primer's components only. The space around them is part of your own layout.

To use the same scale in your own components, read it with [`usePrimerTheme`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/primer-theme-override#useprimertheme):

```tsx theme={"dark"}
import { View } from 'react-native';
import type { ReactNode } from 'react';
import { usePrimerTheme } from '@primer-io/react-native';

export function CheckoutSection({ children }: { children: ReactNode }) {
  const { spacing } = usePrimerTheme();
  return <View style={{ gap: spacing.medium, padding: spacing.large }}>{children}</View>;
}
```

## See also

> [card] [PrimerThemeOverride](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/primer-theme-override.md)
>
> Apply a theme, choose light or dark mode and read tokens with usePrimerTheme.

> [card] [Shape tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/shape-tokens.md)
>
> Corner radii, sizes and border widths.

> [card] [Typography tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/typography-tokens.md)
>
> The brand font and the six text styles.

> [card] [Card inputs](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-inputs.md)
>
> Per-input overrides with PrimerTextInputTheme.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.