Example of Basic Card in ASP.NET MVC Card Control
This sample demonstrates card rendering with the following basic weather layout.
Debunking Five Data Science Myths
By John Doe | Jan 20, 2018
Tech evangelists are currently pounding their pulpits about all things AI, machine learning, analytics—anything that sounds like the future and probably involves lots of numbers. Many of these topics can be grouped under the intimidating term data science.
Today
New York - Scattered Showers.
1º / -4º
Chance for snow: 100%
@Html.UiCard(new UiCardOptions
{
Id = "basic_card", Title = "Debunking Five Data Science Myths", SubTitle = "By John Doe | Jan 20, 2018",
Content = "Tech evangelists are currently pounding their pulpits about all things AI, machine learning, analytics\u2014anything that sounds like the future and probably involves lots of numbers. Many of these topics can be grouped under the intimidating term data science.",
Actions = { new UiCardAction { Text = "Read More" } }
})
@Html.UiCard(new UiCardOptions
{
Id = "weather_card", Title = "Today", SubTitle = "New York - Scattered Showers.",
Template = @<div class="weather_report"><img src="@Url.Content("~/Content/card/rainy.svg")" alt="Rainy" width="56" height="56" /><div><div class="weather-title">1º / -4º</div><div class="weather-sub">Chance for snow: 100%</div></div></div>
})
<style>
.card-layout { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; max-width: 900px; margin: 0 auto; padding: 20px 0; }
.card-layout > * { flex: 0 1 380px; min-width: 260px; }
.card-layout .ui-card { width: 100%; box-sizing: border-box; }
.card-layout .ui-card + .ui-card { margin-top: 20px; }
.card-layout p { margin: 0; }
.weather_report { display: flex; align-items: center; gap: 12px; }
.weather-title { font-weight: 600; }
.weather-sub { color: var(--ui-muted); font-size: 13px; }
</style>
<div class="control-section card-control-section basic_card_layout">
<div class="card-layout">
<div>
@Html.UiCard(new UiCardOptions
{
Id = "basic_card", Title = "Debunking Five Data Science Myths", SubTitle = "By John Doe | Jan 20, 2018",
Content = "Tech evangelists are currently pounding their pulpits about all things AI, machine learning, analytics\u2014anything that sounds like the future and probably involves lots of numbers. Many of these topics can be grouped under the intimidating term data science.",
Actions = { new UiCardAction { Text = "Read More" } }
})
</div>
<div>
@Html.UiCard(new UiCardOptions
{
Id = "weather_card", Title = "Today", SubTitle = "New York - Scattered Showers.",
Template = @<div class="weather_report"><img src="@Url.Content("~/Content/card/rainy.svg")" alt="Rainy" width="56" height="56" /><div><div class="weather-title">1º / -4º</div><div class="weather-sub">Chance for snow: 100%</div></div></div>
})
</div>
</div>
</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/BasicCard.cshtml; it draws what ViewData holds.
public ActionResult BasicCard()
{
return View();
}
}
}
@* 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 card is a small content display area in which specific structure of the content can be shown. This sample demonstrates the defined structure and predefined classes for adding basic cards with header, and content elements.