Customize Card Element

Customise the Card Element's appearance using theme presets, CSS variables, custom rules, and element-specific options.

Element Options

Option Type Description
hideIconbooleanHide the card brand icon
iconStyle'solid' | 'default'Card brand icon style
showInlineErrorsbooleanShow validation errors inline (default: true)
showAcceptedBrandsbooleanShow accepted card brand logos
disabledbooleanDisable user input

Theme Presets

Six built-in theme presets are available:

const teya = await initTeyaBlocks('session-token', {
  appearance: {
    theme: 'default', // default | dark | minimal | rounded | compact | bold
  },
});

Theme Variables

Override individual CSS variables using appearance.variables:

const teya = await initTeyaBlocks('session-token', {
  appearance: {
    variables: {
      colorPrimary: '#0055ff',
      colorBackground: '#ffffff',
      colorText: '#333333',
      colorDanger: '#dc3545',
      borderRadius: '8px',
      fontFamily: 'Inter, sans-serif',
      fontSizeBase: '16px',
    },
  },
});

Custom CSS Rules

const teya = await initTeyaBlocks('session-token', {
  appearance: {
    rules: {
      '.Input': { border: '1px solid #ccc', padding: '12px' },
      '.Input:focus': { borderColor: '#0055ff' },
      '.Input--invalid': { borderColor: '#dc3545' },
      '.Label': { fontWeight: '600' },
    },
  },
});

Callbacks

Callback Description
onReadyFired when the element is ready for input
onChangeFired when element state changes
onFocusFired when the element gains focus
onBlurFired when the element loses focus
onSuccessFired on successful payment
onErrorFired on payment failure
onTokenRefreshCalled when session token needs refreshing

Handling common flows

Payment success: The onSuccess callback receives a PaymentSubmitResponse with a payment_id. Redirect the customer to a confirmation page or update your UI.

Payment error: The onError callback receives an error object with message and optional code. Display the error to the customer and allow them to retry.

3D Secure: 3DS challenges are handled automatically by the SDK. The challenge modal appears within the card element iframe. No additional code is needed - the onSuccess or onError callback fires after the challenge completes.

Dynamic Currency Conversion (DCC): If DCC is enabled for your store, the SDK may offer the customer a choice of currencies. Use the DCC callbacks (onDccOffered, onDccSelectionRequired, onDccSelected) to track the customer's currency preference. The final payment amount reflects their choice.

Updating the pay button: Use the onChange callback to enable/disable your submit button based on event.complete. This ensures the button is only clickable when all fields are valid.

Fonts & Locales

See the Embedded Checkout Customize page for the full list of built-in fonts and supported locales - they apply to all elements.