- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner (Toast)
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Trace
Card
Displays a card with header, content, and footer.
Login to your account
Enter your email below to login to your account
import { Component } from '@angular/core';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmCardImports } from '@spartan-ng/helm/card';
import { HlmInputImports } from '@spartan-ng/helm/input';
import { HlmLabelImports } from '@spartan-ng/helm/label';
@Component({
selector: 'spartan-card-preview',
imports: [HlmCardImports, HlmLabelImports, HlmInputImports, HlmButtonImports],
host: { class: 'w-full max-w-md' },
template: `
<hlm-card class="w-full max-w-sm">
<hlm-card-header>
<h3 hlmCardTitle>Login to your account</h3>
<p hlmCardDescription>Enter your email below to login to your account</p>
<div hlmCardAction>
<button hlmBtn variant="link">Sign Up</button>
</div>
</hlm-card-header>
<div hlmCardContent>
<form id="login-form">
<div class="flex flex-col gap-6">
<div class="grid gap-2">
<label hlmLabel for="email">Email</label>
<input type="email" id="email" placeholder="m@example.com" required hlmInput />
</div>
<div class="grid gap-2">
<div class="flex items-center">
<label hlmLabel for="password">Password</label>
<a href="#" class="ml-auto inline-block text-sm underline-offset-4 hover:underline">
Forgot your password?
</a>
</div>
<input type="password" id="password" hlmInput />
</div>
</div>
</form>
</div>
<hlm-card-footer class="flex-col gap-2">
<button hlmBtn type="submit" class="w-full" form="login-form">Login</button>
<button hlmBtn variant="outline" class="w-full">Login with Google</button>
</hlm-card-footer>
</hlm-card>
`,
})
export class CardPreview {}Installation
ng g @spartan-ng/cli:ui cardnx g @spartan-ng/cli:ui cardUsage
import { HlmCardImports } from '@spartan-ng/helm/card';<hlm-card>
<hlm-card-header>
<h3 hlmCardTitle>Card Title</h3>
<p hlmCardDescription>Card Description</p>
<div hlmCardAction>Card Action</div>
</hlm-card-header>
<div hlmCardContent>Card Content</div>
<hlm-card-footer>Card Footer</hlm-card-footer>
</hlm-card>Examples
Size
Use the size="sm" prop to set the size of the card to small. The small size variant uses smaller spacing.
Small Card
This card uses the small size variant.
The card component supports a size prop that can be set to "sm" for a more compact appearance.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmCardImports } from '@spartan-ng/helm/card';
@Component({
selector: 'spartan-card-size-preview',
imports: [HlmCardImports, HlmButtonImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-card size="sm" class="mx-auto w-full max-w-sm">
<hlm-card-header>
<h3 hlmCardTitle>Small Card</h3>
<p hlmCardDescription>This card uses the small size variant.</p>
</hlm-card-header>
<div hlmCardContent>
<p>The card component supports a size prop that can be set to "sm" for a more compact appearance.</p>
</div>
<hlm-card-footer>
<button hlmBtn variant="outline" size="sm" class="w-full">Action</button>
</hlm-card-footer>
</hlm-card>
`,
})
export class CardSizePreview {}Spacing
In addition to the size prop, you can use the --card-spacing CSS variable to control the spacing between sections and the inset of card parts.
Login to your account
Enter your email below to login to your account
import { Component, computed, signal } from '@angular/core';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmCardImports } from '@spartan-ng/helm/card';
import { HlmInputImports } from '@spartan-ng/helm/input';
import { HlmLabelImports } from '@spartan-ng/helm/label';
import { HlmToggleGroupImports } from '@spartan-ng/helm/toggle-group';
@Component({
selector: 'spartan-card-spacing',
imports: [HlmCardImports, HlmLabelImports, HlmInputImports, HlmButtonImports, HlmToggleGroupImports],
host: { class: 'w-full max-w-md grid gap-4' },
template: `
<hlm-toggle-group type="single" size="sm" variant="outline" spacing="2" [(value)]="spacing">
@for (space of spacingOptions; track $index) {
<button hlmToggleGroupItem [value]="space.value" [aria-label]="'Toggle ' + space.label">
{{ space.label }}
</button>
}
</hlm-toggle-group>
<hlm-card class="w-full max-w-sm" [class]="spacingClass()">
<hlm-card-header>
<h3 hlmCardTitle>Login to your account</h3>
<p hlmCardDescription>Enter your email below to login to your account</p>
<div hlmCardAction>
<button hlmBtn variant="link">Sign Up</button>
</div>
</hlm-card-header>
<div hlmCardContent>
<form id="login-form">
<div class="flex flex-col gap-6">
<div class="grid gap-2">
<label hlmLabel for="email">Email</label>
<input type="email" id="email" placeholder="m@example.com" required hlmInput />
</div>
<div class="grid gap-2">
<div class="flex items-center">
<label hlmLabel for="password">Password</label>
<a href="#" class="ml-auto inline-block text-sm underline-offset-4 hover:underline">
Forgot your password?
</a>
</div>
<input type="password" id="password" hlmInput />
</div>
</div>
</form>
</div>
<hlm-card-footer class="flex-col gap-2">
<button hlmBtn type="submit" class="w-full" form="login-form">Login</button>
<button hlmBtn variant="outline" class="w-full">Login with Google</button>
</hlm-card-footer>
</hlm-card>
`,
})
export class CardSpacing {
public readonly spacing = signal('4');
public readonly spacingOptions = [
{
className: '[--card-spacing:--spacing(4)]',
label: '16px',
value: '4',
},
{
className: '[--card-spacing:--spacing(5)]',
label: '20px',
value: '5',
},
{
className: '[--card-spacing:--spacing(6)]',
label: '24px',
value: '6',
},
{
className: '[--card-spacing:--spacing(8)]',
label: '32px',
value: '8',
},
];
public readonly spacingClass = computed(
() => this.spacingOptions.find((option) => option.value === this.spacing())?.className,
);
} Use negative margins with -mx-(--card-spacing) to make content go edge to edge while keeping it aligned with the card inset. When the edge-to-edge content sits above a footer, use -mb-(--card-spacing) on hlmCardContent to remove the section gap.
Terms of Service
Review the terms before accepting the agreement.
These terms govern your use of the workspace, including access to shared documents, project files, and collaboration tools.
You are responsible for the content you upload and for ensuring that your team has the appropriate permissions to view or edit it.
We may update features or limits as the service evolves. When those changes materially affect your workflow, we will notify your workspace administrators.
By continuing, you agree to keep your account credentials secure and to follow your organization's acceptable use policies.
import { Component } from '@angular/core';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmCardImports } from '@spartan-ng/helm/card';
import { HlmInputImports } from '@spartan-ng/helm/input';
import { HlmLabelImports } from '@spartan-ng/helm/label';
@Component({
selector: 'spartan-card-edge-to-edge',
imports: [HlmCardImports, HlmLabelImports, HlmInputImports, HlmButtonImports],
host: { class: 'w-full max-w-md' },
template: `
<hlm-card class="mx-auto w-full max-w-sm">
<hlm-card-header>
<h3 hlmCardTitle>Terms of Service</h3>
<p hlmCardDescription>Review the terms before accepting the agreement.</p>
</hlm-card-header>
<div hlmCardContent class="-mb-(--card-spacing)">
<div
class="bg-muted/50 -mx-(--card-spacing) max-h-48 space-y-4 overflow-y-scroll border-t px-(--card-spacing) py-4 text-sm leading-relaxed"
>
<p>
These terms govern your use of the workspace, including access to shared documents, project files, and
collaboration tools.
</p>
<p>
You are responsible for the content you upload and for ensuring that your team has the appropriate
permissions to view or edit it.
</p>
<p>
We may update features or limits as the service evolves. When those changes materially affect your workflow,
we will notify your workspace administrators.
</p>
<p>
By continuing, you agree to keep your account credentials secure and to follow your organization's
acceptable use policies.
</p>
</div>
</div>
<hlm-card-footer class="justify-end gap-2 pt-(--card-spacing)">
<button hlmBtn variant="outline">Decline</button>
<button hlmBtn>Accept</button>
</hlm-card-footer>
</hlm-card>
`,
})
export class CardEdgeToEdge {}Image
Design systems meetup
A practical talk on component APIs, accessibility, and shipping faster.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmBadgeImports } from '@spartan-ng/helm/badge';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmCardImports } from '@spartan-ng/helm/card';
@Component({
selector: 'spartan-card-image-preview',
imports: [HlmCardImports, HlmButtonImports, HlmBadgeImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-card class="relative mx-auto w-full max-w-sm pt-0">
<div class="bg-primary absolute inset-0 z-30 aspect-video opacity-50 mix-blend-color"></div>
<img
src="https://images.unsplash.com/photo-1604076850742-4c7221f3101b?q=80&w=1887&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
alt="Event cover"
class="relative z-20 aspect-video w-full object-cover brightness-60 grayscale dark:brightness-40"
/>
<hlm-card-header>
<div hlmCardAction>
<span hlmBadge variant="secondary">Featured</span>
</div>
<h3 hlmCardTitle>Design systems meetup</h3>
<p hlmCardDescription>A practical talk on component APIs, accessibility, and shipping faster.</p>
</hlm-card-header>
<hlm-card-footer>
<button hlmBtn class="w-full">View Event</button>
</hlm-card-footer>
</hlm-card>
`,
})
export class CardImagePreview {}RTL
To enable RTL support in spartan-ng, see the RTL configuration guide.
تسجيل الدخول إلى حسابك
أدخل بريدك الإلكتروني أدناه لتسجيل الدخول إلى حسابك
import { Component, computed, inject } from '@angular/core';
import { TranslateService, Translations } from '@spartan-ng/app/app/shared/translate.service';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmCardImports } from '@spartan-ng/helm/card';
import { HlmInputImports } from '@spartan-ng/helm/input';
import { HlmLabelImports } from '@spartan-ng/helm/label';
@Component({
selector: 'spartan-card-rtl',
imports: [HlmCardImports, HlmLabelImports, HlmInputImports, HlmButtonImports],
host: { class: 'w-full max-w-md' },
template: `
<hlm-card class="w-full max-w-sm" [dir]="_dir()">
<hlm-card-header>
<h3 hlmCardTitle>{{ _t()['title'] }}</h3>
<p hlmCardDescription>{{ _t()['description'] }}</p>
<div hlmCardAction>
<button hlmBtn variant="link">{{ _t()['signUp'] }}</button>
</div>
</hlm-card-header>
<div hlmCardContent>
<form id="login-form-rtl">
<div class="flex flex-col gap-6">
<div class="grid gap-2">
<label hlmLabel for="email">{{ _t()['email'] }}</label>
<input type="email" id="email" placeholder="{{ _t()['emailPlaceholder'] }}" required hlmInput />
</div>
<div class="grid gap-2">
<div class="flex items-center">
<label hlmLabel for="password">{{ _t()['password'] }}</label>
<a href="#" class="ms-auto inline-block text-sm underline-offset-4 hover:underline">
{{ _t()['forgotPassword'] }}
</a>
</div>
<input type="password" id="password" hlmInput />
</div>
</div>
</form>
</div>
<hlm-card-footer class="flex-col gap-2">
<button hlmBtn type="submit" class="w-full" form="login-form-rtl">{{ _t()['login'] }}</button>
<button hlmBtn variant="outline" class="w-full">{{ _t()['loginWithGoogle'] }}</button>
</hlm-card-footer>
</hlm-card>
`,
})
export class CardRtl {
private readonly _language = inject(TranslateService).language;
private readonly _translations: Translations = {
en: {
dir: 'ltr',
values: {
title: 'Login to your account',
description: 'Enter your email below to login to your account',
signUp: 'Sign Up',
email: 'Email',
emailPlaceholder: 'm@example.com',
password: 'Password',
forgotPassword: 'Forgot your password?',
login: 'Login',
loginWithGoogle: 'Login with Google',
},
},
ar: {
dir: 'rtl',
values: {
title: 'تسجيل الدخول إلى حسابك',
description: 'أدخل بريدك الإلكتروني أدناه لتسجيل الدخول إلى حسابك',
signUp: 'إنشاء حساب',
email: 'البريد الإلكتروني',
emailPlaceholder: 'm@example.com',
password: 'كلمة المرور',
forgotPassword: 'نسيت كلمة المرور؟',
login: 'تسجيل الدخول',
loginWithGoogle: 'تسجيل الدخول باستخدام Google',
},
},
he: {
dir: 'rtl',
values: {
title: 'התחבר לחשבון שלך',
description: 'הזן את האימייל שלך למטה כדי להתחבר לחשבון שלך',
signUp: 'הירשם',
email: 'אימייל',
emailPlaceholder: 'm@example.com',
password: 'סיסמה',
forgotPassword: 'שכחת את הסיסמה?',
login: 'התחבר',
loginWithGoogle: 'התחבר עם Google',
},
},
};
private readonly _translation = computed(() => this._translations[this._language()]);
protected readonly _t = computed(() => this._translation().values);
protected readonly _dir = computed(() => this._translation().dir);
}Helm API
HlmCardAction
Selector: [hlmCardAction]
ExportAs: hlmCardAction
HlmCardContent
Selector: [hlmCardContent]
ExportAs: hlmCardContent
HlmCardDescription
Selector: [hlmCardDescription]
ExportAs: hlmCardDescription
HlmCardFooter
Selector: [hlmCardFooter],hlm-card-footer
ExportAs: hlmCardFooter
HlmCardHeader
Selector: [hlmCardHeader],hlm-card-header
ExportAs: hlmCardHeader
HlmCardTitle
Selector: [hlmCardTitle]
ExportAs: hlmCardTitle
HlmCard
Selector: [hlmCard],hlm-card
ExportAs: hlmCard
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| size | HlmCardConfig['size'] | this._defaultConfig.size | - |
On This Page