Card Component
The VCP Card Component is a wrapper component for the Bootstrap card class. It supports all the features that Bootstrap card component provides.
VCP Card Component has three main components, CardHeader, CardBody and CardFooter. These components have their own class and style inputs
| Component | Selector | Input Properties |
|---|---|---|
| CardHeader | vcp-card-header |
cardHeaderClass,cardHeaderStyle |
| CardBody | vcp-card-body |
cardBodyClass,cardBodyStyle |
| CardFooter | vcp-card-footer |
cardFooterClass,cardFooterStyle |
In addition to these components, the Card component provides directives like CardHeader,CardTitle,CardSubtitle,CardImgTop.
| Directive | Selector |
|---|---|
| CardHeader | vcp-card-header,[vcp-card-header],[vcpCardHeader] |
| CardTitle | vcp-card-title,[vcp-card-title],[vcpCardTitle] |
| CardSubtitle | vcp-card-subtitle,[vcp-card-subtitle],[vcpCardSubtitle] |
| CardImgTop | vcp-card-img-top,[vcp-card-img-top],[vcpCardImgTop] |
Usage
VCP Card Component is a part of the ThemeSharedModule module. If you've imported that module into your module, you don't need to import it again. If not, first import it as shown below:
// my-feature.module.ts
import { ThemeSharedModule } from '@vcp/ng.theme.shared';
import { CardDemoComponent } from './card-demo.component';
@NgModule({
imports: [
ThemeSharedModule ,
// ...
],
declarations: [CardDemoComponent],
// ...
})
export class MyFeatureModule {}
Then, the vcp-card component can be used. See the examples below:
CardBody
// card-demo.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-card-demo',
template: `
<vcp-card [cardStyle]="{width: '18rem'}">
<vcp-card-body>This is some text within a card body</vcp-card-body>
</vcp-card>
`,
})
export class CardDemoComponent { }
See the card body result below:
Titles, Text and Links
//card-demo.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-card-demo',
template: `
<vcp-card [cardStyle]="{width: '18rem'}">
<vcp-card-body>
<h5 vcpCardTitle>Card Title</h5>
<h6 vcpCardSubtitle class="mb-2 text-muted">Card subtitle</h6>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="card-link" >Card link</a>
<a href="#" class="card-link" >Another link</a>
</vcp-card-body>
</vcp-card>
`,
})
export class CardDemoComponent { }
See the card title, text and link result below:
Images
//card-demo.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-card-demo',
template: `
<vcp-card [cardStyle]="{width:'18rem'}">
<img vcpCardImgTop src="..." alt="...">
<vcp-card-body>
<p class="card-text" >Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</vcp-card-body>
</vcp-card>
`,
})
export class CardDemoComponent { }
See the card image result below:
List Groups
//card-demo.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-card-demo',
template: `
<vcp-card [cardStyle]="{width:'18rem'}">
<ul class="list-group list-group-flush">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
</vcp-card>
`,
})
export class CardDemoComponent { }
See the group list result below:
Kitchen Sink
//card-demo.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-card-demo',
template: `
<vcp-card [cardStyle]="{width:'18rem'}">
<img vcpCardImgTop src="../../assets/thinh-nguyen-aRrS37GKlVA-unsplash.jpg" alt="...">
<vcp-card-body>
<h5 vcpCardTitle>Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</vcp-card-body>
<ul class="list-group list-group-flush">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<vcp-card-body>
<a href="#" class="card-link">Card link</a>
<a href="#" class="card-link">Another link</a>
</vcp-card-body>
</vcp-card>
`,
})
export class CardDemoComponent { }
See kitchen sink result below:
Header and Footer
//card-demo.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-card-demo',
template: `
<vcp-card class="text-center">
<vcp-card-header>Featured</vcp-card-header>
<vcp-card-body>
<h5 vcpCardTitle>Special title treatment</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<a class="card-link" href="#" class="btn btn-primary">Go somewhere</a>
</vcp-card-body>
<vcp-card-footer class="text-muted">
2 days ago
</vcp-card-footer>
</vcp-card>
`,
})
export class CardDemoComponent { }
See the header and footer result below:





