Bodygram

Configuration

All options available when initializing the Body2Fit SDK.

Configuration Object

The Body2Fit SDK is initialized with a configuration object that contains all the necessary settings:

const config = {
    // Required fields
    clientKey: "your-client-key",
    countryCode: "US",
    languageCode: "en",
    brandId: "your-brand-id",
    garmentSKU: "your-garment-sku",
    preferredMeasurementSystem: "metric",

    // Optional fields
    priorityFlow: "stats",
    features: ["shinyAvatar", "avatarLighting:studio", "weightInterval5"],
    brandLogoURL: "https://example.com/logo.png",
    garmentImageURL: "https://example.com/garment.jpg",
    garmentName: "Premium T-Shirt",
    slideInDirection: "right",
    preferredGender: "male",
    theme: {
        primary: "oklch(0.4127 0.0935 257.5)",
        primaryForeground: "oklch(0.98 0 0)",
    },
    additionalParams: {
        customParam: "value"
    },
    session: {
        clientSessionId: "your-client-session-id",
    },
};

const widget = new Body2FitSDK(config);

Required Configuration

PropertyTypeValuesDescription
clientKeystringYour unique client key provided by Body2Fit.
countryCodestring"US", "JP"The country code for your target market.
languageCodestring"en", "ja"The language code for the widget interface.
brandIdstringYour unique brand identifier.
garmentSKUstringThe SKU of the specific garment for size recommendations.
preferredMeasurementSystemstring"metric", "imperial"The measurement system to use for the widget.

Optional Configuration

PropertyTypeDefaultValuesDescription
priorityFlowstring"stats""stats", "upload", "selfie", "full-body"Determines the priority flow for the widget experience.
featuresstring[][]Array of feature flags to enable specific functionality. See Features for the supported flags.
brandLogoURLstringValid URLURL to your brand logo image.
garmentImageURLstringValid URLURL to the garment product image.
garmentNamestringDisplay name for the garment.
slideInDirectionstring"right""left", "right", "top", "bottom"Direction from which the widget slides in.
preferredGenderstring"male""male", "female"Default gender preference for the widget.
themeobject{}Custom theme configuration for styling. See Theme for the full structure.
additionalParamsobject{}Custom key-value pairs for integration-specific data.
session.clientSessionIdstringA unique identifier to correlate size recommendations with purchase decisions. Generate a unique ID per user session and pass it here to enable order tracking. See Order Confirmation.

Features

The features option enables optional widget capabilities. Pass an array of supported feature flags:

const widget = new Body2FitSDK({
  // ... other required config
  features: ["shinyAvatar", "avatarLighting:studio", "weightInterval5"],
});

Supported flags

FlagDescription
shinyAvatarRenders the avatar with a shiny, reflective surface.
avatarLighting:studioApplies studio-style lighting to the avatar (removes shadows on the avatar).
weightInterval5Adds 5 kg intervals to the weight slider.

Unknown flags are ignored. Contact Bodygram if you need a feature that isn't listed here.


Theme

The theme option lets you override the widget's appearance by setting CSS custom properties. The widget uses the same CSS variable system as Tailwind CSS theme variables — any variable Tailwind exposes (e.g. --primary, --background, --radius, --font-sans) can be set through this option.

How it works

Each key in the theme object is converted from camelCase to kebab-case and applied as a CSS custom property on the widget root. For example:

theme keyCSS variable applied
primary--primary
primaryForeground--primary-foreground
background--background
radius--radius

Values are passed through unchanged, so you can use any valid CSS color format (oklch(), hsl(), rgb(), hex, etc.) or any value supported by the underlying CSS variable.

Example

const widget = new Body2FitSDK({
  // ... other required config
  theme: {
    primary: "oklch(0.4127 0.0935 257.5)",
    primaryForeground: "oklch(0.98 0 0)",
    background: "oklch(1 0 0)",
    radius: "0.5rem",
  },
});

Dark theme

Dark theme is not fully supported yet. We are actively working on it. If you need dark theme support urgently, please contact Bodygram.

The theme object accepts a nested dark key for dark-mode overrides, but the widget does not yet apply these reliably across all flows. For now, we recommend providing only light-theme values at the top level of theme and omitting the dark key.


Configuration Validation

The SDK validates your configuration and throws descriptive errors for missing or invalid required fields:

try {
    const widget = new Body2FitSDK({
        clientKey: "demo-key",
        // Missing required fields
    });
} catch (error) {
    console.error("Configuration error:", error.message);
    // Error: Body2Fit: brandId is required
}

Common validation errors:

ErrorCause
clientKey is requiredclientKey was not provided.
brandId is requiredbrandId was not provided.
garmentSKU is requiredgarmentSKU was not provided.
countryCode is requiredcountryCode was not provided or is invalid.
languageCode is requiredlanguageCode was not provided or is invalid.
measurementSystem is requiredpreferredMeasurementSystem was not provided or is invalid.

On this page