How to use Ample React Dashboard Lite Template for your projects
In this tutorial, you will know how to use?WrapPixel’s Ample React Dashboard Lite Template?for React which is a free template housing the necessary things needed for your personal or a commercial project.?
Here’s how the entire tutorial is laid up for you in different sections:
Ready to use the Ample React Dashboard Lite Template, let’s go!
Template overview
The entire template is free to use. It’s great for you if you are just starting to look out for a suitable theme for your next project be it personal or a professional one. It is entirely modular so you can easily configure and change every content you desire.
Keeping in mind that most beginners will use it, there aren’t many technologies or frameworks used here. For starters, the template deals with?React?as its main library to build all the dashboard components and it is styled with?Sass?and CSS.
If you are one of those developers who fear having a bad user interface in your applications, then fret not. The Ample template was built to be an elegant yet beautiful solution for stunning interfaces. Be to about the page layout, the choice of icons, or even the fonts and colors. There is no need to think more about UI/UX choices for you. It’s all covered.
Now let’s take a quick look at what all you will get in this template:
If you feel you have a project that needs more features and customizations than the Ample free version, then you can always opt for the Ample React Dashboard premium version. It includes a truckload of features with advanced components, widgets, elements, and tools.
Download, install and setup
Let’s start with the download and installation. For this, you need to have a WrapPixel account. Simply head over to?the website?and create one. After your account is created, follow these simple steps:
npm i
This will install all the required dependencies and libraries or tooling required in order to run the template properly in your machine. When it’s finished you can then head on to run another command which will eventually start the React script to run the app:
npm start
Wait for a few seconds and it will open up the React development server in your browser at the address?https://localhost:3000/.
If you have successfully completed the steps above you will see something like this:
Congratulations! With just 5 easy steps you have set up the React template to work according to your needs.
Examining the project structure
Time to take a close look at how everything is set up inside this folder. If you see, the overall project structure looks like any other React application:
```
ample-react-dashboard-lite
│ package.json
│ package-lock.json
│
└───src
│ │ index.js
│ │ logo.svg
| | registerServiceWorker.js
│ │
│ └───assets
│ │ file1
│ │ file2
│ │ ...
│ └───components
│ │ file1
│ │ file2
│ │ ...
│ └───layouts
│ │ file1
│ │ file2
│ │ ...
│ └───routes
│ │ file1
│ │ file2
│ │ ...
│ └───views
│ │ file1
│ │ file2
│ │ ...
│
└───public
│ index.html
│ ...
```
Let’s see what each sub-folder means:
Deep dive into important files and dependencies
Onto the sweet stuff! Let’s see what some of the important files you will be using thoroughly while customizing the template by yourself along with the dependencies used by default.
useEffect(() => {
const updateDimensions = () => {
let element = document.getElementById('main-wrapper');
setWidth(window.innerWidth)
if (width < 1170) {
element.setAttribute("data-sidebartype", "mini-sidebar");
element.classList.add("mini-sidebar");
} else {
element.setAttribute("data-sidebartype", "full");
element.classList.remove("mini-sidebar");
}
}
if (document.readyState === "complete") {
updateDimensions();
}
window.addEventListener("resize", updateDimensions.bind(this));
window.addEventListener("load", updateDimensions.bind(this));
return () => {
window.removeEventListener("load", updateDimensions.bind(this));
window.removeEventListener("resize", updateDimensions.bind(this));
};
}, [width]);
This essentially uses the?useEffect()?hook under-the-hood to call the?updateDimensions?function which in turn, enables or disables the sidebar as needed.
{
path: "/slider",
name: "Slider",
icon: "fa fa-sliders",
component: SliderComponent,
},
If you need to apply a new UI component like?Breadcrumb, you first need to import it:
import { Breadcrumb, BreadcrumbItem } from 'reactstrap';
Then, inside the?Starter?function, you can add it under the?<Row>?component:
领英推荐
<Breadcrumb>
<BreadcrumbItem active>Home</BreadcrumbItem>
</Breadcrumb>
let lineData = {
labels: ["2011", "2012", "2013", "2014", "2015"],
datasets: [
{
label: "My Income",
borderWidth: 1.2,
backgroundColor: "rgba(44,171,227,.1)",
borderColor: "rgb(44,171,227)",
pointBorderColor: "rgb(44,171,227)",
pointBackgroundColor: "rgb(44,171,227)",
data: [0, 6, 11, 25, 24],
},
],
};
Now let’s take a look at the different third-party dependencies used:
A quick look at components
All of the components used reside under the?/components?folder in this template. Broadly, they are categorized into 4 types:
Now let’s see what do we get under the dashboard-components section:
The entire interface is a child of the <Card /> component which comes from the ReactStrap library. Inside this, you have the?CardBody />?which houses all the necessary elements like an unordered list with links, image, name, and status text. When you hover over an item on the list it will show up two icons of chat and phone. Here how it is laid in code:
<li className="mb-3">
<a href="/">
<div className="d-flex align-items-center">
<img src={img1} className="rounded-circle" alt="" width="40" />
<div className="ml-3">
<h5 className="mb-0 text-dark">Varun Dhavan</h5>
<small className="text-success">Online</small>
</div>
<div className="ml-auto chat-icon">
<button
type="button"
className="btn btn-success btn-circle btn-circle text-white"
>
<i className="fas fa-phone"></i>
</button>
<button
type="button"
className="btn btn-info btn-circle btn-circle ml-2"
>
<i className="far fa-comments"></i>
</button>
</div>
</div>
</a>
</li>
You first have to define the data as explained above and then pass on the data?object as a?data?attribute prop of the?<Line />?component used from the React Chart library. Along with that, you can also pass several options to it like?legend,?scales, etc:
<Line
data={lineData}
options={{
maintainAspectRatio: false,
legend: {
display: false,
labels: { fontFamily: "Rubik" },
},
scales: {
yAxes: [
{
stacked: true,
gridLines: { display: false },
ticks: { fontFamily: "Rubik" },
},
],
xAxes: [
{
gridLines: { display: false },
ticks: { fontFamily: "Rubik" },
},
],
},
}}
/>
These are 4 individual cards that show the total income, number of users, birthday and the pending work to be done. Everything is contained in the?<Row />?component of ReactStrap with?<CardBody />?being its child. Inside this, you get an icon, the text with a?<h3>?and?<span>?tags for each of them.
<Col md={6} lg={3}>
<Card>
<CardBody>
<div className="d-flex flex-row">
<div className="round align-self-center round-success">
<i className="ti-wallet"></i>
</div>
<div className="ml-3 align-self-center">
<h3 className="mb-0">$18090</h3>
<span className="text-muted">Income</span>
</div>
</div>
</CardBody>
</Card>
</Col>
The good part is that we also get to approve or reject a comment right from the home layout. Not only that this template also comes with the status of approval next to the author’s name. All in all, it uses the?badge,?badge-info,?badge-rounded?to make this happen.
<div className="d-flex flex-row comment-row mt-0 mb-0">
<div className="p-2">
<img
src={img1}
alt="user"
width="40"
className="rounded-circle"
/>
</div>
<div className="comment-text w-100">
<h5 className="font-normal mb-1">Pavan kumar</h5>
<span className="text-muted mr-2 font-12">
10:20 AM 20 may 2016
</span>
<span className="badge badge-info badge-rounded text-uppercase font-medium">
Pending
</span>
<span className="mb-2 d-block font-14 text-muted font-light mt-3">
Donec ac condimentum massa. Etiam pellentesque pretium lacus.
Phasellus ultricies dictum suscipit. Aenean commodo
</span>
<div className="mt-3">
<a
href="javacript:void(0)"
className="btn btn btn-rounded btn-outline-success mr-2 btn-sm"
>
<i className="ti-check mr-1"></i>Approve
</a>
<a
href="javacript:void(0)"
className="btn-rounded btn btn-outline-danger btn-sm"
>
<i className="ti-close mr-1"></i> Reject
</a>
</div>
</div>
</div>
Everything comes under the?Table />?ReactStrap component which defines the border type, the table headers?<th>?and its body?<tbody>.
<tbody>
<tr>
<td>1</td>
<td>Elite Admin</td>
<td>
<span className="text-uppercase">Sale</span>
</td>
<td>April 18, 2017</td>
<td className="text-success">$24</td>
</tr>
<tr>
<td>2</td>
<td>Real Homes WP Theme</td>
<td>EXTENDED</td>
<td>April 19, 2017</td>
<td className="text-info">$1250</td>
</tr>
<tr>
<td>3</td>
<td>Ample Admin</td>
<td className="text-uppercase">EXTENDED</td>
<td>April 19, 2017</td>
<td className="text-info font-medium">$1250</td>
</tr>
<tr>
<td>4</td>
<td>Medical Pro WP Theme</td>
<td>TAX</td>
<td>April 20, 2017 </td>
<td className="text-danger">-$24</td>
</tr>
<tr>
<td>5</td>
<td>Hosting press html </td>
<td>SALE</td>
<td>April 21, 2017 </td>
<td className="text-success">$24</td>
</tr>
<tr>
<td>6</td>
<td>Digital Agency PSD</td>
<td>SALE</td>
<td>April 23, 2017</td>
<td className="text-danger">-$14</td>
</tr>
<tr>
<td>7</td>
<td>Helping Hands WP Theme</td>
<td>MEMBER</td>
<td>April 22, 2017</td>
<td className="text-success">$64</td>
</tr>
</tbody>
If you want to take your design skills to the full extent, then you might need to make any changes to the overall layout of the template. For this, the best part would be to change all the layout settings provided in the?fulllayout.jsx?file which resides under the?/src/layouts/?directory.
Here you can change the header, sidebar, and dark layout. For example, if you have made a completely new?MyHeader.jsx?component and now want to include it in the Ample template you have to follow these simple steps:
import MyHeader from '../components/MyHeader.jsx';
return (
<div
id="main-wrapper"
data-theme="light"
data-layout="vertical"
data-sidebartype="full"
data-sidebar-position="fixed"
data-header-position="fixed"
data-boxed-layout="full"
>
<MyHeader />
...
</div>
);
And there you go! Now you know almost all of the features, customization methods, and a deep explanation of all the major files included in the Ample React Dashboard Lite there.
Try this free template and don’t miss to also consider its Pro version which has a lot more to offer!