Skip to main content
Each Cashfree.js component is initialised with a configuration object that allows you to customise both its behaviour and appearance and integrate it with your application’s design system.
All configuration options are optional, components use default styles if not specified. The style object supports most CSS properties in camelCase format. Custom fonts in the fonts array are loaded automatically before the component renders. Use disabled to temporarily prevent user interaction (e.g., during form submission). Use loader to show or hide loading states while the component initialises.
Configuration is passed as the second argument to cashfree.create():

Configuration options

Select an option below to jump to its detailed customisation guide.

classes

CSS class names applied per state

style

Inline CSS styles applied per state

fonts

Custom fonts to load inside the component

values

Initial values to pre-fill the component

disabled

Load the component in a disabled state

loader

Show a skeleton loader during initialisation

Appearance and styling

Use these options to define how the component looks and how it integrates with your application’s design system.

classes

Type: object Apply CSS class names to the component container. The SDK automatically adds or removes classes based on the component’s state. You do not need to add them to your HTML manually.
Define these classes in your application’s CSS. The SDK applies them dynamically; do not add them to the DOM container yourself.

States

Each state maps to a CSS class you define in your stylesheet. The SDK adds and removes these classes automatically as the component’s state changes.

Default values

If you do not supply your own class names, the SDK uses the following internal defaults. These classes are not exposed in your stylesheet, so override them by specifying custom names.

Usage

Pass a classes object inside options when calling cashfree.create(). Only include the states you want to override; any omitted states fall back to their defaults.

CSS examples by state

Expand any state below to see a JavaScript snippet alongside a matching CSS example.
Applied to the container at all times. Use this for base or default styling. If you do not provide a value, the default cf-base-private is applied.
Applied when the user has entered a complete, valid value (for example, a valid card number). Note that not all components apply a complete class. Default is cf-complete-private.
Applied when the component has no value, for example when the user has not yet typed anything. Default is cf-empty-private.
Applied when the component receives keyboard focus, for example when the user clicks into the card number input. Default is cf-focus-private.
Applied when the component contains invalid data, for example when the user has entered an incorrect card number. Default is cf-invalid-private.
Applied when you have disabled the component. The classes.disabled styling is combined with any style.base[":disabled"] rules you have set. Default is cf-disabled-private.

style

Type: object Apply inline CSS styles directly to the component’s content. The style object supports most CSS properties in camelCase format (for example, fontSize instead of font-size). Styles can be defined per state: base, complete, empty, and invalid.

Default values

The SDK applies the following style defaults when no style option is provided. Only base.fontSize and invalid.color are set out of the box; all other states start empty.

Usage

Pass a style object inside options to override the default appearance for one or more states. You only need to include the states and properties you want to change.

Pseudo-classes and pseudo-elements

You can target interactive states and placeholder text by nesting pseudo-class and pseudo-element keys inside any state object. Use these inside style.base (or any other state) as shown below. Supported values:

fonts

Type: array Load custom fonts to match your application’s typography. Fonts specified in the fonts array are loaded automatically before the component renders, and are injected into the component’s iframe so they render correctly in the secure context.

Default value

When no fonts are specified, the component inherits whatever fonts are already available in the browser environment.

Option 1: CSS URL

Reference a CSS file that contains @font-face definitions (for example, a Google Fonts URL):

Option 2: Font file with parameters

Specify individual font files with full parameters. Both src and fontFamily are required; all other properties are optional.
You can specify multiple fonts and reference them by fontFamily name inside the style option.

Behaviour and initialisation

Control the initial state, disabled status, and loading experience of your components.

values

Type: object Pre-fill a component with a starting value. The available keys depend on the component type. Visit sections under different components to get all the available keys.

Default value

If no initial values are provided, the component renders empty and waits for user input.

Usage

Pass the keys relevant to the component type you are creating. Keys that are not recognised by the component are silently ignored.

Examples by component

Expand the component type below to see the accepted value keys and an example pre-filled value.

disabled

Type: boolean Load the component in a disabled state. Use this to temporarily prevent user interaction (e.g., during form submission). When true, the component applies classes.disabled and style.base[":disabled"] styling automatically.

Default value

Components load in an enabled (interactive) state by default.

Usage

Set disabled to true when you need to prevent user interaction, for example during form submission or while an earlier step in your checkout flow is still loading.

loader

Type: boolean Show or hide a skeleton loader UI while the component initialises. Use this to control loading states during initialisation. Not all components support this option.

Default value

The skeleton loader is enabled by default, so users see a visual placeholder immediately while the component iframe initialises.

Usage

Set loader to false if you prefer to handle the loading state yourself, or if the component does not support it.

Complete example

The following example demonstrates all configuration options used together to create a fully customised payment component: