> ## 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.

# PrimerThemeOverride

> The light and dark design-token overrides you pass to PrimerCheckoutProvider through its theme prop.

> [!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.

`PrimerThemeOverride` is the type of the `theme` prop on [`PrimerCheckoutProvider`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider). It holds design-token overrides for light mode and dark mode, and every Primer component inside the provider draws with the result.

The SDK ships a default set of tokens for each mode. Your `light` overrides are merged onto the light defaults and your `dark` overrides onto the dark defaults, one key at a time. You set only the tokens you want to change. A token you leave out keeps its default, except that some colors follow another color you set. See [Tokens that follow others](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/color-tokens.md#tokens-that-follow-others).

## Type

```tsx theme={"dark"}
interface PrimerThemeOverride {
  light?: {
    colors?: Partial<PrimerColorTokens>;
    spacing?: Partial<PrimerSpacingTokens>;
    typography?: PrimerTypographyOverride;
    radii?: Partial<PrimerRadiusTokens>;
    sizes?: Partial<PrimerSizeTokens>;
    widths?: Partial<PrimerWidthTokens>;
  };
  dark?: {
    colors?: Partial<PrimerColorTokens>;
    spacing?: Partial<PrimerSpacingTokens>;
    typography?: PrimerTypographyOverride;
    radii?: Partial<PrimerRadiusTokens>;
    sizes?: Partial<PrimerSizeTokens>;
    widths?: Partial<PrimerWidthTokens>;
  };
}
```

| Field | Type | Description |
| - | - | - |
| `light` | object | Overrides used in light mode. Leave it out to use the light defaults. |
| `dark` | object | Overrides used in dark mode. Nothing carries over from `light`. Leave it out to use the dark defaults. |

### Token groups

Each mode takes the same six optional groups.

| Group | Type | Covers | Reference |
| - | - | - | - |
| `colors` | `Partial<PrimerColorTokens>` | 32 colors: brand, backgrounds, text, borders, icons, focus, loader and the sheet backdrop | [Color tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/color-tokens.md) |
| `spacing` | `Partial<PrimerSpacingTokens>` | The seven-step padding and gap scale | [Spacing tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/spacing-tokens.md) |
| `typography` | `PrimerTypographyOverride` | The brand font and six text styles | [Typography tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/typography-tokens.md) |
| `radii` | `Partial<PrimerRadiusTokens>` | The corner radius scale | [Shape tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/shape-tokens.md) |
| `sizes` | `Partial<PrimerSizeTokens>` | The size scale | [Shape tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/shape-tokens.md) |
| `widths` | `Partial<PrimerWidthTokens>` | Border widths for the default, focus, selected and error states | [Shape tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/shape-tokens.md) |

## Apply a theme

Pass the theme to `PrimerCheckoutProvider`. It styles every Primer component inside the provider: `PrimerCheckoutSheet`, and the components you compose in a custom layout.

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

const theme: PrimerThemeOverride = {
  light: {
    colors: { brand: '#6c5ce7' },
    radii: { medium: 12 },
  },
  dark: {
    colors: { brand: '#a29bfe' },
    radii: { medium: 12 },
  },
};

export function CheckoutScreen({ clientToken }: { clientToken: string }) {
  const [visible, setVisible] = useState(true);

  return (
    <PrimerCheckoutProvider clientToken={clientToken} theme={theme}>
      <PrimerCheckoutSheet visible={visible} onRequestDismiss={() => setVisible(false)} />
    </PrimerCheckoutProvider>
  );
}
```

> [!TIP]
>
> Define the theme outside your component, or build it with `useMemo`. The provider merges the tokens again each time it receives a new `light` or `dark` object, so a theme written inline in JSX is merged again on every render. To switch themes at runtime, pass a new object: the components restyle on the next render.

### Values the SDK ignores

* `null` or `undefined` keeps the default for that token.
* A `NaN` or infinite number keeps the default, and the SDK logs the warning `[PrimerCheckoutTheme] A NaN or infinite theme number is ignored.`

## Light and dark mode

Set `settings.uiOptions.appearanceMode` on the provider to choose which set of tokens applies.

| Value | Description |
| - | - |
| `'SYSTEM'` | Follows the device's light or dark setting. Same as leaving it unset. |
| `'LIGHT'` | Always uses the light tokens. |
| `'DARK'` | Always uses the dark tokens. |

When the device reports no preference, the checkout uses light mode. The provider reads `appearanceMode` on every render, so a change applies right away.

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

const settings: PrimerSettings = {
  uiOptions: { appearanceMode: 'DARK' },
};

export function DarkCheckout({ clientToken, children }: { clientToken: string; children: ReactNode }) {
  return (
    <PrimerCheckoutProvider clientToken={clientToken} settings={settings}>
      {children}
    </PrimerCheckoutProvider>
  );
}
```

## usePrimerTheme

```tsx theme={"dark"}
function usePrimerTheme(): PrimerTokens
```

Returns the tokens in effect: the defaults for the active mode with your overrides merged in. Use it to style your own UI, such as a custom Pay button, so it matches Primer's components.

Inside a `PrimerCheckoutProvider`, the result follows your `theme` and `appearanceMode`. Outside one, it returns the default tokens for the device's light or dark setting, without your overrides and without `appearanceMode`. Primer components that can render outside a provider, such as the [status screens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/status-screens.md), use those defaults too.

### Returns

`PrimerTokens`:

| Field | Type | Description |
| - | - | - |
| `colors` | `PrimerColorTokens` | All 32 colors. |
| `spacing` | `PrimerSpacingTokens` | The spacing scale, `xxsmall` to `xxlarge`. |
| `typography` | `PrimerTypographyTokens` | The brand font and the six text styles. Every style has its `fontFamily` filled in. |
| `radii` | `PrimerRadiusTokens` | The corner radius scale, `xsmall` to `large`. |
| `sizes` | `PrimerSizeTokens` | The size scale, `small` to `xxxlarge`. |
| `widths` | `PrimerWidthTokens` | Border widths: `default`, `focus`, `selected` and `error`. |

### Example

```tsx theme={"dark"}
import { Pressable, Text } from 'react-native';
import { usePrimerTheme } from '@primer-io/react-native';

export function PayButton({ onPress }: { onPress: () => void }) {
  const { colors, radii, spacing, typography } = usePrimerTheme();
  const label = typography.titleLarge;

  return (
    <Pressable
      accessibilityRole="button"
      onPress={onPress}
      style={{
        alignItems: 'center',
        backgroundColor: colors.brand,
        borderRadius: radii.medium,
        padding: spacing.medium,
      }}
    >
      <Text
        style={{
          color: colors.onBrand,
          fontFamily: label.fontFamily,
          fontSize: label.fontSize,
          fontWeight: label.fontWeight,
          letterSpacing: label.letterSpacing,
          lineHeight: label.lineHeight,
        }}
      >
        Pay
      </Text>
    </Pressable>
  );
}
```

## Fonts

Every text style uses the brand font, `typography.fontFamily`, unless the style sets its own. The default is Inter. It ships inside the package and the SDK registers it, so it needs no setup.

To use your own font, register it in your app as you would any React Native font, then set its family name as `typography.fontFamily` under both `light` and `dark`. See [Typography tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/typography-tokens.md).

## Per-input overrides

Each Primer input also takes a `theme` prop of type `PrimerTextInputTheme`, which overrides the tokens for that one input. See [Card inputs](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/card-form/card-inputs.md).

## Exported types

Import these with `import type { ... } from '@primer-io/react-native'`.

| Type | Reference |
| - | - |
| `PrimerThemeOverride`, `PrimerTokens` | This page |
| `PrimerColorTokens` | [Color tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/color-tokens.md) |
| `PrimerSpacingTokens` | [Spacing tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/spacing-tokens.md) |
| `PrimerTypographyTokens`, `PrimerTypographyStyle`, `PrimerTypographyOverride`, `PrimerTypographyStyleOverride` | [Typography tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/typography-tokens.md) |
| `PrimerRadiusTokens`, `PrimerSizeTokens`, `PrimerWidthTokens` | [Shape tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/shape-tokens.md) |

## See also

> [card] [Color tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/color-tokens.md)
>
> All 32 colors with their light and dark defaults.

> [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] [Spacing tokens](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/spacing-tokens.md)
>
> The padding and gap scale.

> [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.


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