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:
| Option | Type | Default | Description |
|---|---|---|---|
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. |
hideCardHeader | boolean | false | When 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):
- State-specific category styles (e.g.,
state.hover.card) - Default category styles (
state.default.card) globalStylespassed toFastSpring.init(), which is applied as base defaults across all components
Hover legacy: Use
state.hover.card.backgroundColorandstate.hover.card.borderColorinstead of the olderbackgroundColorOnHover/borderColorOnHovershortcuts.
Available states
| State | When applied |
|---|---|
default | Always (the base styling) |
focus | Any input inside the card has keyboard focus (:host(:focus-within)) |
hover | The customer hovers over the card panel |
error | The 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
card: the panelThe outer container for the card form.
| Property | Type | Default | Description |
|---|---|---|---|
backgroundColor | string | #fff | Panel background color |
borderColor | string | #DEE2E6 | Panel border color |
borderWidth | string | 1px | Panel border width |
borderRadius | string | 8px | Panel corner radius |
border | string | (none) | Shorthand border (e.g. '2px solid navy'); overrides borderColor and borderWidth when set |
boxShadow | string | 0 2px 6px rgba(0,0,0,0.06) | Panel box shadow |
padding | string | 0 | Inner padding |
width | string | 100% | Panel width. Use '100%' to fill the container, or a fixed value such as '500px' |
maxWidth | string | 680px | Maximum 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. |
gap | string | 0 | Gap between form rows |
fontSize | string | 16px | Base font size |
fontFamily | string | ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial | Base font family (system font stack) |
color | string | #4B5563 | Base text color |
iconColor | string | rgb(75, 85, 99) | Fill color of the credit card SVG icon in the panel header. Hidden when hideCardHeader: true. |
cardTitle: the header title
cardTitle: the header titleStyles 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.
| Property | Type | Default | Description |
|---|---|---|---|
color | string | #4B5563 | Title text color |
fontSize | string | 16px | Title font size |
fontWeight | string | 500 | Title font weight |
fontFamily | string | Helvetica | Title font family |
input: all input fields
input: all input fieldsUse input to style all card fields at once. To target individual fields, use cardNumber, expiry, or cvv instead; they accept the same properties.
| Property | Type | Default | Description |
|---|---|---|---|
backgroundColor | string | #fff | Input background color. Always applied as background-color (never the background shorthand). This preserves the card-brand badge image on the card-number field. |
borderColor | string | #DEE2E6 | Input border color |
borderRadius | string | 6px | Input corner radius |
color | string | #4B5563 | Input text color |
fontSize | string | 16px | Input font size |
fontFamily | string | Helvetica | Input font family |
height | string | 48px | Input field height |
padding | string | 0 16px | Input inner padding |
margin | string | 0 | Input outer margin. Routed through --fsc-input-margin; the grid layout deducts this from available space so inputs never overflow the card. |
outline | string | (none) | Focus-ring shorthand (e.g. '1px solid #bfdbfe'). Sets the full CSS outline shorthand. |
outlineColor | string | #bfdbfe | Focus-ring color only. Flat alternative to setting outline as a shorthand. |
errorBorderColor | string | #e53935 | Border color in error state |
placeholderColor | string | #7D8A9B | Flat 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. |
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
cardNumber, expiry, cvv: per-field overridesEach 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
cvvIcon: CVV graphicA 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.
| Property | Type | Default | Description |
|---|---|---|---|
height | string | 25px | Icon height; width scales proportionally |
outlineColor | string | #B9B9B9 | The grey structural parts: card-shaped rectangle on the left and circle border on the right. Think "frame." |
accentColor | string | #008AFF | The colored digit strokes inside the circle. Think "content." |
backgroundColor | string | transparent | Background fill behind the icon. Useful to match the input background. |
changeCard: "Use a different card" link
changeCard: "Use a different card" link| Property | Type | Default | Description |
|---|---|---|---|
color | string | #6b7280 | Link text color |
fontSize | string | 14px | Link font size |
fontFamily | string | Helvetica | Link font family |
inlineError: inline validation error messages
inlineError: inline validation error messages| Property | Type | Default | Description |
|---|---|---|---|
color | string | #EB1431 | Error message text color |
fontSize | string | 12px | Error message font size |
fontWeight | string | 400 | Error message font weight |
backgroundColor | string | transparent | Error 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
focusApplied when any input inside the card has keyboard focus.
| Property | Default override value |
|---|---|
input.borderColor | #4d90fe |
input.focusShadow | 0 0 0 4px rgba(0, 138, 255, .2) (soft blue glow) |
hover
hoverApplied when the customer hovers over the card panel. SDK defaults match the default-state values. Override them to add visual differentiation.
active
activeApplied when the card region is clicked. Adds a blue accent to the panel border and a bolder title.
| Property | Default override value |
|---|---|
card.borderColor | #008aff |
cardTitle.fontWeight | 600 |
error
errorApplied when the card is in an error state.
| Property | Default override value |
|---|---|
card.borderColor | #e53935 |
input.borderColor | #e53935 (from input.errorBorderColor) |
input.color | #e53935 |
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
- Integration Guide: end-to-end integration walkthrough.
- Pay Button: the companion component that submits the payment.
- Disclosures: reseller disclosure block.
