Urgent.News

What's breaking now, across thousands of outlets.

Tech

Build an Admin Dashboard in React

An admin dashboard is mostly three things: a row of numbers that matter, a chart that shows the trend, and a table of recent activity. In this tutorial we build all three with oks-ui and arrange them in a layout that works from phone to desktop. import { Card } from " oks-ui/card " ; import " oks-ui/card.css " ; import { Stat } from " oks-ui/stat " ; import " oks-ui/stat.css " ; import { Chart }…

Building an admin dashboard in React involves creating three key components: KPI cards, a revenue chart, and a table of recent activity. These components are arranged in a layout that adapts from phone to desktop. The hardest part of creating a dashboard is not the coding process, but determining what information to display.

To decide what to show on the dashboard, apply this test: each number on the first screen should answer a question someone actually asks every day. For instance, "How much did we sell this week?" warrants a card. Conversely, "Total registered users since launch" is less useful, as it only ever increases and doesn't prompt any action.

When designing the dashboard, limit the top row to four numbers. Each number should be accompanied by its change over a comparable period, as a number without context can't indicate whether the current situation is good or bad. Place the detail, such as the chart and the table, beneath the top row. This placement ensures users can focus on the high-level numbers first and then delve into the additional information when needed.

First, KPI cards serve as the foundation of the dashboard. The `Stat` component displays a label, a significant value, and an optional change with a direction indicator. The direction color-codes the change pill and selects the arrow. Here's an example code snippet for creating KPI cards:

```javascript

const kpis = [

{ label: 'Revenue', value: '$48,210', delta: '+12.4%', trend: 'up' },

{ label: 'Orders', value: '1,284', delta: '+3.1%', trend: 'up' },

{ label: 'Refunds', value: '18', delta: '-2', trend: 'down' },

{ label: 'Conversion', value: '3.2%', delta: '0.0%', trend: 'flat' },

] as const;

<div className="kpi-grid">

{kpis.map((k) => (

<Card

key={k.label}

shadow="sm"

radius="lg"

style={{ padding: 20 }}

>

<Stat

label={k.label}

value={k.value}

delta={k.delta}

trend={k.trend}

/>

</Card>

))}

</div>

```

Next, a revenue chart is created using the `Chart` component. This component takes rows of data, the key for the x-axis, and the series to draw. Multiple series automatically generate a legend. Here's an example of a revenue chart:

```javascript

const revenue = [

{ month: 'Jan', online: 12400, store: 8200 },

{ month: 'Feb', online: 13900, store: 7900 },

{ month: 'Mar', online: 15100, store: 8800 },

{ month: 'Apr', online: 16800, store: 9100 },

{ month: 'May', online: 18200, store: 9600 },

{ month: 'Jun', online: 21000, store: 10400 },

];

<Card

shadow="sm"

radius="lg"

style={{ padding: 20 }}

>

<Chart

type="area"

title="Revenue"

// Additional chart properties...

/>

</Card>

```

Finally, a table of recent activity is added beneath the KPI cards and revenue chart. This table provides additional context and detail to the user. The `Table` component, along with the `TableColumn` type, can be used to create the table structure.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Building a High-Performance Safari Content Blocker on iOS with Declarative WebKit Rules

Introduction: The State of Ad Blocking on iOS When developing ad-blocking solutions on iOS, developers face a major architectural choice between: Declarative WebKit Content Blockers (…

  • AdBlocker Pro uses declarative WebKit Content Blocker API for on-device rule execution.
  • Leverages modular content extensions to bypass strict rule count limits.
  • Achieves high performance with minimal memory footprint (~12 MB RAM).

The silent retry bug killing ASP.NET Core reliability (and how idempotency keys save you)

The Silent Retry Bug: Why Your Resilient .NET System Is Actually Fragile If you’ve spent any time working with distributed systems in C# and ASP.NET Core, you know the drill: network calls fail…

  • Distributed systems in ASP.NET Core experience network issues like timeouts.
  • Conventional retry policies from Polly can cause data inconsistency.
  • Idempotency Keys prevent duplicate-state problem by ensuring state-changing requests are unique.

Two things nobody was watching

First published on openspec-ui.dev . OpenSpec Workbench's whole pitch is watching an agent while it works. Two small fixes this week are about the product not watching itself closely enough - one…

  • Cleanup process stopped prematurely, leaving 54 MB Visual Studio Code file
  • DeepSeek CLI failed to read crucial usage number
  • OpenSpec Workbench fixed both issues with new changes

More from Tuesday 6 October →