Getting Started
16 Mar 20234 minutes to read
This section explains how to create a simple Card using styles by configuring the structure for the header, content, using Essential JS 2 quickstart seed repository.
Prerequisites
System requirements for Syncfusion Vue UI components
Dependencies
The Card is pure CSS component so no other package dependencies are needed to render the Card.
|-- @syncfusion/ej2-layouts
Get Started with Vue CLI
You can use Vue CLI
to setup your vue applications.
To install Vue CLI use the following command.
npm install -g @vue/cli
Start a new project using below Vue CLI command.
vue init webpack-simple quickstart
cd quickstart
npm install
Adding Syncfusion packages
All the available Essential JS 2 packages are published in npmjs.com
registry.
You can choose the component that you want to install. For this application, we are going to use Card component.
To install Card component, use the following command
npm install @syncfusion/ej2-vue-layouts –save
Registering Vue Component
For Registering Vue Component two ways are available. They are as follows.
- Vue.use()
- Vue.component()
Since the Card is a pure CSS component there is no need to refer the scripts
Creating Vue Sample
Add the HTML div element with e-card class into the <template>
section of the App.vue
file in src directory, the content attribute of the Card component is provided as name in data option in the <script>
section.
<template>
<div id="app">
<div class = "e-card">
Sample Card
</div>
</div>
</template>
<script>
import Vue from 'vue';
export default {
name: 'app',
}
</script>
Adding CSS Reference
Add Card component’s styles as given below in <style>
section of the App.vue
file.
<style>
@import '../../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../../node_modules/@syncfusion/ej2-vue-layouts/styles/material.css';
</style>
Adding a header and content
You can create Card with a header in a specific structure. For adding header you need to create a div
element with e-card-header
class added.
- You can include heading inside the Card header by adding a
div
element withe-card-header-caption
class, and also content will be added by adding element withe-card-content
. For detailed information, refer to the Header and Content.
<div class = "e-card"> --> Root Element
<div class="e-card-header"> --> Root Header Element
<div class="e-card-header-caption"> --> Root Heading Element
<div class="e-card-header-title"></div> --> Heading Title Element
</div>
<div class="e-card-content"></div> --> Card content Element
</div>
</div>
Running the Application
Now run the npm run dev
command in the console, it will build your application and open in the browser.
<template>
<div id="app">
<div id='container' style="margin:50px auto 0; width:100%;">
<br>
<div tabindex="0" class="e-card" id="basic">
<div class="e-card-header">
<div class="e-card-header-caption">
<div class="e-card-title">Advanced UWP</div>
</div>
</div>
<div class="e-card-content">
Communicating with Windows 10 and Other Apps, the second in a five-part series written by Succinctly series
author Matteo Pagani. To download the complete white paper, and other papers in the series, visit
the White Paper section of Syncfusion’s Technology Resource Portal.
</div>
</div>
</div>
</div>
</template>
<script>
import Vue from 'vue';
export default {
name: 'app',
}
</script>
<style>
@import "../../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-vue-layouts/styles/material.css";
</style>