# Customising Your Payment Fields

## Making Your Payment Forms Look Great

Want to match your brand's look and feel? You can easily customise the appearance of your payment fields using our styling options. Here's how to make your checkout experience seamlessly integrate with your website design.

## Getting Started with Field Styling

To customise how your payment fields look, simply use the `styles` property when setting up your payment form. Think of it like CSS for your payment fields - you can control colours, fonts, and other visual elements to create the perfect user experience.

Here's a practical example to get you started:

```javascript
const customStyles = {
  'input': {
    'font-size': '16px',
    'color': '#3A3A3A'
  },
  '::placeholder': {
    'color': 'blue'
  },
  ':focus': {
    'color': 'blue'
  },
  ':hover': {
    'font-style': 'italic'
  },
  ':disabled': {
    'cursor': 'not-allowed',
  },
  'valid': {
    'color': 'green'
  },
  'invalid': {
    'color': 'red'
  }
};

const flex = new Flex('..........');
// Apply your custom styles to all payment fields
const microform = flex.microform({ styles: customStyles });
const securityCode = microform.createField('securityCode');

// You can also override styles for specific fields
const number = microform.createField('number', { 
  styles: { 
    input: { color: '#000' }
  }
});
```

## Automatic State Management

Our system automatically adds helpful CSS classes to your payment field containers based on what's happening with the form. This makes it easy to style different states without extra work on your part.

| Class Name | What It Means |
| --- | --- |
| `.flex-microform` | Applied to any container with a payment field |
| `.flex-microform-disabled` | Shows when a field is disabled |
| `.flex-microform-focused` | Active when a user clicks into a field |
| `.flex-microform-valid` | Applied when the card number is valid |
| `.flex-microform-invalid` | Shows when there's an invalid card number |
| `.flex-microform-autocomplete` | Indicates the field was filled automatically |

## Available Styling Options

We support a comprehensive set of CSS properties to give you maximum flexibility while maintaining security. Here's what you can customise:

### Text and Typography

Perfect for matching your brand's font choices and text styling:

-   `color` - Set text colours
-   `font-family` - Choose your preferred fonts
-   `font-size` - Control text size
-   `font-weight` - Make text bold or light
-   `font-style` - Add italic styling
-   `line-height` - Adjust spacing between lines
-   Plus many more font properties for fine-tuning

### Visual Effects

Add polish and interactivity to your forms:

-   `cursor` - Change how the cursor looks on hover
-   `opacity` - Control transparency
-   `text-shadow` - Add subtle shadows to text
-   `text-rendering` - Optimise text display

### Smooth Interactions

Make your forms feel responsive and professional:

-   `transition` - Create smooth colour and style changes
-   Browser-specific transition properties for maximum compatibility

### Enhanced Display

Optimise how your text appears across different devices:

-   Font smoothing properties for crisp text rendering
-   Tap highlight controls for mobile experiences

## Pro Tips for Success

**Keep it simple:** Start with basic styling like colours and fonts, then add more advanced effects as needed.

**Test across devices:** Your payment forms will be used on phones, tablets, and desktops - make sure they look great everywhere.

**Match your brand:** Use your website's existing colours and fonts to create a cohesive checkout experience.

**Consider accessibility:** Ensure good contrast ratios and readable font sizes for all users.

**Security first:** We only support safe CSS properties, so you can style with confidence knowing your payment forms remain secure.

Ready to create payment forms that perfectly match your brand? Start with the basic example above and customise from there!
