A beautiful, animated credit card component with real-time updates and brand detection
$ dotnet add package Soenneker.Blazor.CreditCards
Soenneker.Blazor.CreditCardsdotnet add package Soenneker.Blazor.CreditCards
dotnet add package Soenneker.Blazor.CreditCards
builder.Services.AddCreditCardsInteropAsScoped();
<CreditCard CardNumber="@CardNumber"
CardholderName="@CardholderName"
ExpiryDate="@ExpiryDate"
Cvc="@Cvc"
FlipEnabled="true"
OnClick="HandleCardClick"
@ref="_creditCard" />
### 3. Handle click events (optional)
```csharp
private async Task HandleCardClick(MouseEventArgs args)
{
// Example: Flip the card when clicked
_creditCard?.Flip();
// Or perform any other action
Console.WriteLine($"Card clicked at: {args.ClientX}, {args.ClientY}");
}
<!-- Enable/disable flip functionality -->
<CreditCard FlipEnabled="false" ... />
<!-- Default behavior: flip is enabled -->
<CreditCard FlipEnabled="true" ... />
FlipEnabled Parameter:
true (default): Card can be flipped by clicking or programmaticallyfalse: Disables flip functionality, cursor changes to default, and Flip() method does nothing// Flip the card programmatically
_creditCard?.Flip();
// Set last 4 digits only (for saved cards)
await _creditCard?.SetLast4("1234", "visa");
// Reset to full input mode
_creditCard?.ResetCardDetection();