- CSS-in-JS: Apply React
CSSPropertiesdirectly for precise control - CSS classes: Use custom classes for state styling, animations, and responsive design
CSS-in-JS Styling
Direct React CSS properties for precise control over form elements.
CSS Class Names
Custom classes for advanced styling with pseudo-selectors and responsive design.
Implement Brand Styles
Integrate the checkout form with your design system using CSS custom properties:CSS custom properties enable dynamic theming without JavaScript and generally perform better than heavy inline style changes.
Configure StylesConfig
TheStylesConfig interface provides styling options for all checkout form elements.
Define your
StylesConfig objects and pass them into the styles property when calling checkout.mount('element-id', { ...config, styles }), following the pattern in Mount the Checkout.Core Elements
Configure card number, expiry, CVC, cardholder name, etc.
Styles for the payment submit button.
Digital Wallet Buttons
Apple Pay button styling following Apple’s guidelines.
PayPal button styling following PayPal specifications.
Google Pay button styling.
Cash App Pay button styling (Stripe wallets only).
Styles for generic wallet buttons (e.g., custom wallet implementations).
Styles for Braintree payment buttons.
Styles for the back button wrapper that sits above the card form (hidden when the default variant hides the control). Defaults include a 30x30px flex container with centered content, a
#f4f4f5 background, and 8px border radius.Override the SDK design tokens directly from
styles without adding external stylesheets. Values apply to the checkout root element and merge with the active theme.Leave any variable undefined to keep the theme default. See Theme Support › CSS Variables for the complete token list and defaults.
css-variables.constant.ts
Element-level styling properties support both
Wallet button styling must also follow each processor’s brand guidelines (Apple, PayPal, Google) to remain compliant.
styles (React CSSProperties) and className, while cssVariables overrides global tokens for the entire checkout.Wallet button styling must also follow each processor’s brand guidelines (Apple, PayPal, Google) to remain compliant.
Target Elements with External CSS
The SDK addsdata-paynext-* attributes to key elements, enabling CSS targeting from external stylesheets without modifying JavaScript:
| Attribute | Element |
|---|---|
data-paynext-component="checkout" | Main checkout container |
data-paynext-version="1.0" | SDK version attribute |
data-paynext-element="card-number-wrapper" | Card number field outer wrapper |
data-paynext-element="card-number-container" | Card number input container (receives focus styles) |
data-paynext-element="card-number-input" | Card number input field |
data-paynext-element="card-number-label" | Card number label |
data-paynext-element="card-number-error-label" | Card number validation error |
data-paynext-element="card-name-wrapper" | Cardholder name field outer wrapper |
data-paynext-element="card-name-container" | Cardholder name input container (receives focus styles) |
data-paynext-element="card-name-input" | Cardholder name input field |
data-paynext-element="card-name-label" | Cardholder name label |
data-paynext-element="card-name-error-label" | Cardholder name validation error |
data-paynext-element="submit-button" | Submit/Pay button |
external-styles.css
Use Advanced Styling Patterns
These examples demonstrate real-world styling patterns used by production applications. Each example includes performance optimizations and accessibility considerations.All examples below show only the
StylesConfig object. Pass it to checkout.mount('element-id', { ...config, styles }) as shown in Mount the Checkout.- CSS Variables Only
- Enhanced Input Styling
- Combined Approach
css-variables-only.constant.ts
Review Complete Styling Example
Here’s a comprehensive example that demonstrates styling all available components. This configuration is production-ready and includes:- Accessibility compliance: standards
- Performance optimization: Hardware-accelerated transitions
- Cross-browser compatibility: Tested across major browsers
- Mobile responsiveness: Touch-friendly targets and spacing
complete-styling.constant.ts
Apply Best Practices
Use CSS custom properties for design system integration, enabling centralized management, easy theme switching, and team collaboration. For theme-level tokens, prefer cssVariables over inline styles.Follow Common Styling Patterns
Responsive Design
Mobile-First Approach
Mobile-First Approach
Design your checkout form with mobile users in mind first, then enhance for larger screens:
mobile-first.constant.ts
Accessibility Considerations
Accessibility Considerations
Ensure your styling meets accessibility standards:
accessible.constant.ts
quick checks: 16px min text, ≥4.5:1 contrast, visible focus ring, 44px touch targets, no color-only semantics.
Performance Optimization
Performance Optimization
Optimize your styles for better performance:
optimized.constant.ts
Brand Integration
Color Consistency
Use your brand colors consistently across all payment elements to maintain visual cohesion.
Typography Matching
Match your website’s typography by using the same font families and weights in the checkout form.
Border Radius
Maintain consistent border radius values that match your site’s design language.
Animation Timing
Use consistent transition durations (typically 0.2s-0.3s) for a cohesive user experience.
Common Styling Patterns
- Dark Mode
- Minimal Design
dark-mode.constant.ts