Skip to main content

Function Signature

function getPairing(name: string): PairingData | undefined

Description

Retrieves a single font pairing by its unique identifier. This function searches through the Fonttrio registry and returns the matching pairing configuration, or undefined if no pairing with the given name exists.

Parameters

name
string
required
The unique identifier of the pairing to retrieve. Examples include:
  • "agency" - Nordic minimalism with Schibsted Grotesk
  • "architect" - Structured design with Outfit
  • "minimal" - Clean, modern aesthetics
Name matching is case-sensitive and must match exactly.

Return Value

return
PairingData | undefined
Returns the matching PairingData object if found, or undefined if no pairing exists with the given name.

Usage Examples

import { getPairing } from '@/lib/pairings';

const agencyPairing = getPairing('agency');

if (agencyPairing) {
  console.log(`Heading: ${agencyPairing.heading}`);
  console.log(`Body: ${agencyPairing.body}`);
} else {
  console.log('Pairing not found');
}

Example Response

{
  "name": "architect",
  "heading": "Outfit",
  "headingCategory": "sans-serif",
  "body": "Libre Baskerville",
  "bodyCategory": "serif",
  "mono": "IBM Plex Mono",
  "mood": ["structured", "professional"],
  "useCase": ["portfolio", "agency", "architecture"],
  "description": "Structured meets refined. Outfit's geometric precision in headings contrasts beautifully with Libre Baskerville's warm readability, like blueprints meeting handwritten notes.",
  "scale": {
    "h1": {
      "size": "2.5rem",
      "weight": 700,
      "lineHeight": "1.1",
      "letterSpacing": "-0.03em"
    },
    "h2": {
      "size": "2rem",
      "weight": 600,
      "lineHeight": "1.15",
      "letterSpacing": "-0.025em"
    },
    "body": {
      "size": "1rem",
      "lineHeight": "1.6",
      "weight": 400
    }
  },
  "googleFontsUrl": "https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Libre+Baskerville:wght@400;700&family=IBM+Plex+Mono:wght@400;500&display=swap"
}

Notes

Case Sensitivity: Pairing names are case-sensitive. "Agency" will not match "agency". Always use lowercase names as defined in the registry.
Performance: This function uses Array.find() which has O(n) complexity. For repeated lookups, consider caching the result or using a Map-based lookup if you need frequent access.
Always check for undefined before using the returned value. TypeScript will help enforce this check at compile time.

Build docs developers (and LLMs) love