Example of Swipeable Card in ASP.NET MVC Card Control
This sample demonstrates card rendering with stacked layout. You can swipe the card in left or right direction to move the first card to last position.
Sydney is a city on the east coast of Australia. Sydney is the capital city of New South Wales. About four million people live in Sydney which makes it the biggest city in Oceania.

The Eiffel Tower is acknowledged as the universal symbol of Paris and France. It was originally designed by Émile Nouguier and Maurice Koechlin.

Malaysia is one of the Southeast Asian countries, on a peninsula of the Asian continent, to a certain extent; it can be recognized as part of the Asian continent and the northern part of the island of Borneo

New York City has been described as the cultural, financial, and media capital of the world, and exerts a signi ficant impact upon commerce, entertainment, research, technology, education, politics, and sports.

Swipe the top card to the left or right (or press Left or Right when it has the focus).
@Html.UiCard(new UiCardOptions { Id = "swipe_" + city.Alt, Horizontal = true, Swipeable = true, ImageUrl = Url.Content("~/Content/card/" + city.Image), ImageTitle = city.Alt, Content = city.Text, Actions = { new UiCardAction { Text = "Favourite" }, new UiCardAction { Text = "Like" }, new UiCardAction { Text = "Share" } } })
<style>
.swipe-stack { position: relative; width: min(520px, 90vw); height: 260px; margin: 20px auto; }
.swipe-stack .ui-card { position: absolute; inset: 0; margin: 0; }
.swipe-stack .ui-card:nth-last-child(1) { inset: 0 0 0 0; z-index: 4; }
.swipe-stack .ui-card:nth-last-child(2) { inset: 8px -8px -8px 8px; z-index: 3; }
.swipe-stack .ui-card:nth-last-child(3) { inset: 16px -16px -16px 16px; z-index: 2; }
.swipe-stack .ui-card:nth-last-child(4) { inset: 24px -24px -24px 24px; z-index: 1; }
.swipe-note { text-align: center; color: var(--ui-muted); font-size: 13px; margin-top: 40px; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section card-control-section swipe_card_layout">
<div class="card-layout">
<div id="horizontal_product" class="swipe-stack">
@* the last card of the stack is the top one *@
@foreach (var city in ((List<LayoutDemoController.CardCity>)ViewData["cities"]).AsEnumerable().Reverse())
{
@Html.UiCard(new UiCardOptions { Id = "swipe_" + city.Alt, Horizontal = true, Swipeable = true, ImageUrl = Url.Content("~/Content/card/" + city.Image), ImageTitle = city.Alt, Content = city.Text, Actions = { new UiCardAction { Text = "Favourite" }, new UiCardAction { Text = "Like" }, new UiCardAction { Text = "Share" } } })
}
</div>
</div>
<p class="swipe-note">Swipe the top card to the left or right (or press Left or Right when it has the focus).</p>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class CardController : Controller
{
// The page is Views/Card/SwipeableCard.cshtml; it draws what ViewData holds.
public ActionResult SwipeableCard()
{
ViewData["cities"] = new List<CardCity>
{
new CardCity { Alt = "newyork", Image = "newyork.png", Text = "New York City has been described as the cultural, financial, and media capital of the world, and exerts a signi ficant impact upon commerce, entertainment, research, technology, education, politics, and sports." },
new CardCity { Alt = "malaysia", Image = "malaysia.png", Text = "Malaysia is one of the Southeast Asian countries, on a peninsula of the Asian continent, to a certain extent; it can be recognized as part of the Asian continent and the northern part of the island of Borneo" },
new CardCity { Alt = "eiffeltower", Image = "eiffeltower.png", Text = "The Eiffel Tower is acknowledged as the universal symbol of Paris and France. It was originally designed by Émile Nouguier and Maurice Koechlin." },
new CardCity { Alt = "sydney", Image = "sydney.png", Text = "Sydney is a city on the east coast of Australia. Sydney is the capital city of New South Wales. About four million people live in Sydney which makes it the biggest city in Oceania." }
};
return View();
}
/// <summary>A card of the Swipeable Card sample.</summary>
public class CardCity
{
public string Alt { get; set; }
public string Image { get; set; }
public string Text { get; set; }
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
The sample illustrates stacked collection of card overlapping each other, which can be bound to swipe actions to move cards one after the other. CSS animation is used to achieve swiping on every left or right swipe.