Skip to content

Admin dashboard application with charts and sidebar using ReactJS, TailwindCSS, and Chakra UI

Notifications You must be signed in to change notification settings

3omdawy/react-dashboard-app

Repository files navigation

React Dashboard App Static Badge

  • This is an admin dashboard application with many charts and pages created using ReactJS, TailwindCSS, MUI X (for charts), PrimeReact (for datatables and other components), and Chakra UI (for tooltips)
  • It is based on this tutorial, with using MUI X instead of SyncFusion (because MUI X is free)

Technical Highlights

Tailwind CSS

  • For basic installation and usage, see this repo
  • The addition here is adding custom styles in TailwindCSS (e.g. background colors)
  • To do this:
  1. In tailwind.config.js add the needed attributes under the extend section
    extend: {
      fontSize: {
        14: '14px',
      },
      backgroundColor: {
        'main-bg': '#FAFBFB',
        'main-dark-bg': '#20232A',
        'secondary-dark-bg': '#33373E',
        'light-gray': '#F7F7F7',
        'half-transparent': 'rgba(0, 0, 0, 0.5)',
      },
  1. To use the style in the app, simply add the className (e.g. bg-main-bg)

Context

  • The application state is stored using useContext hook in React. See ContextProvider.js

Components

Datatables

image

  1. Install it using npm
npm install primereact
  1. Add its imports and CSS includes
import { DataTable } from "primereact/datatable";
import { Column } from "primereact/column";
import "primereact/resources/themes/lara-light-indigo/theme.css";
  1. Use it
<DataTable
  value={ordersData}
  paginator
  rows={5}
  rowsPerPageOptions={[5, 10, 25, 50]}
  id="gridcomp"
>
  {ordersGrid.map((column) => (
    <Column
      key={column.headerText}
      header={column.headerText}
      body={column.template}
      align={column.textAlign}
      alignHeader={column.textAlign}
      style={{ width: 10 }}
      field={column.field}
      sortable
    ></Column>
  ))}
</DataTable>
  1. Add some options (like sorting by columns in Orders.jsx or global search in Employees.jsx or editing and selecting in Customers.jsx)

Charts

<LineChart
  xAxis={[{ data: SparklineAreaData.dataX }]}
  series={[
    {
      data: SparklineAreaData.dataY,
      color: "blue",
    },
  ]}
  width={300}
  height={200}
  id="line-sparkline"
/>
<SparkLineChart
  xAxis={{ data: SparklineAreaData.dataX }}
  data={SparklineAreaData.dataY}
  width={250}
  height={120}
  colors={["blue"]}
  id="line-sparkline"
  showHighlight={true}
  showTooltip={true}
/>
<BarChart
  xAxis={[
    {
      scaleType: "band",
      data: myStackedChartData.dataX,
    },
  ]}
  series={[
    {
      data: myStackedChartData.dataY1,
      color: "#4b5563",
      stack: "A",
      label: "Expense",
    },
    {
      data: myStackedChartData.dataY2,
      color: "#4ade80",
      stack: "A",
      label: "Budget",
    },
  ]}
  width={320}
  height={360}
  id="stack-chart"
/>

Sidebar

  • An elegant sidebar in React is added where the navigation is done using NavLink from react-router-dom. See Sidebar.jsx
  • Responsive, closes automatically on small screens image

Navbar

  • An elegant navbar in React is added using icons. See Navbar.jsx

image

Theme Setting

  • A side menu is opened for the user to choose the application theme when settings is clicked. See ThemeSettings.jsx.
  • Implementation is done in the ContextProvide and stored in localStorage. See ContextProvider.js
  • Usage: see the usage of currentColor and currentMode

image

WYSWYG Editor

image

Color Picker

  • SwatchesPicker and SketchPicker are added based on react-color. See ColorPicker.jsx

image

Kanban Chart

  • A Kanban chart is added in Kanban.jsx based on this repo image