Card

The Card component (fs-card) renders the payment fields (card number, expiry, and CVV) inside a secure iframe served from FastSpring's domain. Card data never touches your origin, which keeps you out of PCI scope.

This page is the complete reference for the Card component: how to mount it, the options it accepts, the states it exposes for styling, and every style category and property available. For setup context, see the Integration Guide.

Mount

Add a target element to your HTML:

<div id="card-element"></div>

Then create the component from your sdk instance and mount it:

const cardComponent = sdk.components.create('fs-card', {
    // options + style go here
});

cardComponent.mount('#card-element');

Component options

Top-level options passed alongside style:

OptionTypeDefaultDescription
labelMode'fixed' | 'floating''floating'Label placement. 'floating': labels start inside the input as a placeholder and animate to the top-left corner on focus or when the field has a value. 'fixed': labels sit above each input.
hideCardHeaderbooleanfalseWhen true, hides the panel header row (the credit card icon and "Card" title). Useful when you provide your own payment heading above the component.

How styling works

Styling is configured through a style object passed at component creation. Each state contains one or more style categories (card, input, cardTitle, etc.) that group related properties.

sdk.components.create('fs-card', {
    style: {
        state: {
            default: { /* base styles */ },
            hover:   { /* applied on hover */ },
            focus:   { /* applied on focus */ },
            error:   { /* applied in error state */ },
        },
    },
});

Style precedence (most specific wins):

  1. State-specific category styles (e.g., state.hover.card)
  2. Default category styles (state.default.card)
  3. globalStyles passed to FastSpring.init(), which is applied as base defaults across all components

Hover legacy: Use state.hover.card.backgroundColor and state.hover.card.borderColor instead of the older backgroundColorOnHover / borderColorOnHover shortcuts.

Available states

StateWhen applied
defaultAlways (the base styling)
focusAny input inside the card has keyboard focus (:host(:focus-within))
hoverThe customer hovers over the card panel
errorThe card is in an error state (validation or payment failure)

Style categories

Each category below targets a specific part of the Card component. Select a card to jump to its full property reference.

card: the panel

The outer container for the card form.

PropertyTypeDefaultDescription
backgroundColorstring#fffPanel background color
borderColorstring#DEE2E6Panel border color
borderWidthstring1pxPanel border width
borderRadiusstring8pxPanel corner radius
borderstring(none)Shorthand border (e.g. '2px solid navy'); overrides borderColor and borderWidth when set
boxShadowstring0 2px 6px rgba(0,0,0,0.06)Panel box shadow
paddingstring0Inner padding
widthstring100%Panel width. Use '100%' to fill the container, or a fixed value such as '500px'
maxWidthstring680pxMaximum panel width on wide screens. Set to 'none' to remove the cap. When width is fixed, maxWidth matches automatically so the panel is never clipped.
gapstring0Gap between form rows
fontSizestring16pxBase font size
fontFamilystringui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, ArialBase font family (system font stack)
colorstring#4B5563Base text color
iconColorstringrgb(75, 85, 99)Fill color of the credit card SVG icon in the panel header. Hidden when hideCardHeader: true.

cardTitle: the header title

Styles the "Card" text in the card panel header. Supports state variants: set cardTitle under state.hover, state.focus, or state.active to change the title appearance per state.

PropertyTypeDefaultDescription
colorstring#4B5563Title text color
fontSizestring16pxTitle font size
fontWeightstring500Title font weight
fontFamilystringHelveticaTitle font family

input: all input fields

Use input to style all card fields at once. To target individual fields, use cardNumber, expiry, or cvv instead; they accept the same properties.

PropertyTypeDefaultDescription
backgroundColorstring#fffInput background color. Always applied as background-color (never the background shorthand). This preserves the card-brand badge image on the card-number field.
borderColorstring#DEE2E6Input border color
borderRadiusstring6pxInput corner radius
colorstring#4B5563Input text color
fontSizestring16pxInput font size
fontFamilystringHelveticaInput font family
heightstring48pxInput field height
paddingstring0 16pxInput inner padding
marginstring0Input outer margin. Routed through --fsc-input-margin; the grid layout deducts this from available space so inputs never overflow the card.
outlinestring(none)Focus-ring shorthand (e.g. '1px solid #bfdbfe'). Sets the full CSS outline shorthand.
outlineColorstring#bfdbfeFocus-ring color only. Flat alternative to setting outline as a shorthand.
errorBorderColorstring#e53935Border color in error state
placeholderColorstring#7D8A9BFlat alternative to setting '::placeholder'.color. Sets only the placeholder text color.
'::placeholder'object(none)Nested placeholder styles. Supports color, fontSize, fontFamily, fontWeight. Inner defaults: color: #7D8A9B, fontSize: 16px, fontFamily: Helvetica, fontWeight: 400.
Session-driven fields you should know about

Depending on your session configuration, the SDK may also render a Zip Code field and a "Save Payment Details" checkbox alongside the card inputs. These fields do not have dedicated style categories yet.

They inherit base styling from input, but their internal label color, background, and border treatments are not currently overridable through the public style API. If you are building a non-default theme (such as dark mode or borderless), expect these fields to appear slightly off-theme. Additional style hooks may be added in future SDK releases.

Placeholder styling example:

input: {
    '::placeholder': {
        color: '#7D8A9B',
        fontSize: '14px',
    },
}

cardNumber, expiry, cvv: per-field overrides

Each accepts the same properties as input (above) but applies only to the named field. Useful when you want one field styled differently from the others.

cvvIcon: CVV graphic

A small graphic to the right of the CVV input. The icon is a card silhouette with a circle showing where to find the CVV code.

PropertyTypeDefaultDescription
heightstring25pxIcon height; width scales proportionally
outlineColorstring#B9B9B9The grey structural parts: card-shaped rectangle on the left and circle border on the right. Think "frame."
accentColorstring#008AFFThe colored digit strokes inside the circle. Think "content."
backgroundColorstringtransparentBackground fill behind the icon. Useful to match the input background.

changeCard: "Use a different card" link

PropertyTypeDefaultDescription
colorstring#6b7280Link text color
fontSizestring14pxLink font size
fontFamilystringHelveticaLink font family

inlineError: inline validation error messages

PropertyTypeDefaultDescription
colorstring#EB1431Error message text color
fontSizestring12pxError message font size
fontWeightstring400Error message font weight
backgroundColorstringtransparentError message background

Default values per state

Out of the box, the Card visually changes for focus, error, and active. The hover state accepts overrides but applies no default differentiation. Set it explicitly if you want a hover effect.

focus

Applied when any input inside the card has keyboard focus.

PropertyDefault override value
input.borderColor#4d90fe
input.focusShadow0 0 0 4px rgba(0, 138, 255, .2) (soft blue glow)

hover

Applied when the customer hovers over the card panel. SDK defaults match the default-state values. Override them to add visual differentiation.

active

Applied when the card region is clicked. Adds a blue accent to the panel border and a bolder title.

PropertyDefault override value
card.borderColor#008aff
cardTitle.fontWeight600

error

Applied when the card is in an error state.

PropertyDefault override value
card.borderColor#e53935
input.borderColor#e53935 (from input.errorBorderColor)
input.color#e53935
Customizing the Card's background: override hover/focus/active too

If you change state.default.card.backgroundColor to a non-white value (e.g., for a dark theme), the SDK's built-in hover and active states will apply #ffffff and override your custom background on interaction. Always pair a non-default base background with matching overrides on hover, focus, and active:

state: {
  default: { card: { backgroundColor: '#1e293b' } },
  hover:   { card: { backgroundColor: '#1e293b' } },
  focus:   { card: { backgroundColor: '#1e293b' } },
  active:  { card: { backgroundColor: '#1e293b' } },
}

Full example

const cardComponent = sdk.components.create('fs-card', {
    labelMode: 'floating',
    hideCardHeader: false,

    style: {
        state: {
            default: {
                card: {
                    backgroundColor: '#ffffff',
                    border: '1px solid #DEE2E6',
                    borderRadius: '8px',
                    padding: '24px',
                    fontFamily: 'Inter, sans-serif',
                    color: '#1F2937',
                    iconColor: '#4B5563',
                },
                cardTitle: {
                    color: '#1F2937',
                    fontSize: '18px',
                    fontWeight: '600',
                },
                input: {
                    backgroundColor: '#F9FAFB',
                    borderColor: '#E5E7EB',
                    borderRadius: '6px',
                    height: '48px',
                    fontSize: '15px',
                    '::placeholder': {
                        color: '#9CA3AF',
                    },
                },
                cvvIcon: {
                    height: '28px',
                    outlineColor: '#9CA3AF',
                    accentColor: '#2563EB',
                },
                inlineError: {
                    color: '#DC2626',
                    fontSize: '13px',
                },
            },
            focus: {
                input: {
                    borderColor: '#2563EB',
                },
            },
            error: {
                input: {
                    borderColor: '#DC2626',
                },
            },
        },
    },
});

cardComponent.mount('#card-element');

Related pages