opensourceui
GitHubTwitter/X
  1. Home
  2. Components
  3. Table
  4. Tasks Table
Back to Table

Components / Table

Tasks Table

Free Table React component — TasksTable. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.

Project tasks with checkboxes, assignee avatars, and due dates. Tap to mark complete.

Preview

Tasks

1 of 4 done

TaskAssigneeDue
Ship table components
Bidyut KunduBidyut Kundu
Today
Review notification polish
Rupam SenRupam Sen
Tomorrow
Update showcase copy
Ava ChenAva Chen
Mar 12
Fix mobile layout
Sofia OrtizSofia Ortiz
Mar 14

Setup

How to use

Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.

  1. 1

    Run in your terminal:

    $npm install clsx tailwind-merge lucide-react
  2. 2

    Copy lib/cn.ts below. Skip if you already have cn().

  3. 3

    Copy the code below and create components/table/tasks-table.tsx in your project.

  4. 4

    Import and render:

    Example

    import { TasksTable } from "@/components/table/tasks-table";

    <TasksTable />

lib/cn.ts

1
2
3
4
5
6
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

components/table/tasks-table.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
"use client";
 
import Image from "next/image";
import { forwardRef, useState, type ComponentPropsWithoutRef } from "react";
 
import { cn } from "@/lib/cn";
import { Check } from "lucide-react";
 
type Task = Readonly<{
id: string;
title: string;
assignee: string;
avatar: string;
due: string;
done: boolean;
}>;
 
const TASKS: Task[] = [
{
id: "tk1",
title: "Ship table components",
assignee: "Bidyut Kundu",
avatar: "/profile-picture.png",
due: "Today",
done: true,
},
{
id: "tk2",
title: "Review notification polish",
assignee: "Rupam Sen",
avatar: "/woman.png",
due: "Tomorrow",
done: false,
},
{
id: "tk3",
title: "Update showcase copy",
assignee: "Ava Chen",
avatar: "/profile-picture.png",
due: "Mar 12",
done: false,
},
{
id: "tk4",
title: "Fix mobile layout",
assignee: "Sofia Ortiz",
avatar: "/woman.png",
due: "Mar 14",
done: false,
},
];
 
type TasksTableProps = ComponentPropsWithoutRef<"div">;
 
// Project tasks table — tap checkbox to mark done. Assignee avatars, due dates.
export const TasksTable = forwardRef<HTMLDivElement, TasksTableProps>(function TasksTable(
{ className, ...props },
ref,
) {
const [doneIds, setDoneIds] = useState<Set<string>>(() => new Set(["tk1"]));
 
function toggleDone(id: string) {
setDoneIds((prev) => {
const next = new Set(prev);
if (next.has(id)) next.delete(id);
else next.add(id);
return next;
});
}
 
const completed = doneIds.size;
 
return (
<div
ref={ref}
className={cn(
"w-full max-w-lg overflow-hidden rounded-xl border border-neutral-200 bg-white",
className,
)}
{...props}
>
<div className="flex items-center justify-between border-b border-neutral-100 px-4 py-3">
<div>
<p className="text-sm font-semibold text-neutral-900">Tasks</p>
<p className="text-xs text-neutral-500">
{completed} of {TASKS.length} done
</p>
</div>
</div>
 
<table className="w-full border-collapse text-left text-sm">
<thead>
<tr className="text-xs text-neutral-500">
<th className="w-10 px-4 py-2.5" />
<th className="px-2 py-2.5 font-medium">Task</th>
<th className="hidden px-3 py-2.5 font-medium md:table-cell">Assignee</th>
<th className="px-4 py-2.5 font-medium">Due</th>
</tr>
</thead>
<tbody>
{TASKS.map((task) => {
const done = doneIds.has(task.id);
return (
<tr
key={task.id}
className="border-t border-neutral-100 transition-colors hover:bg-neutral-50/80"
>
<td className="px-4 py-3">
<button
type="button"
onClick={() => toggleDone(task.id)}
aria-label={done ? "Mark incomplete" : "Mark complete"}
className={cn(
"flex size-4 items-center justify-center rounded border transition-colors",
done
? "border-neutral-900 bg-neutral-900"
: "border-neutral-300 bg-white hover:border-neutral-400",
)}
>
{done ? <Check className="size-2.5 text-white" strokeWidth={3} /> : null}
</button>
</td>
<td className="px-2 py-3">
<span
className={cn(
"font-medium transition-colors",
done ? "text-neutral-400 line-through" : "text-neutral-900",
)}
>
{task.title}
</span>
</td>
<td className="hidden px-3 py-3 md:table-cell">
<div className="flex items-center gap-2">
<Image
src={task.avatar}
alt={task.assignee}
width={24}
height={24}
className="size-6 shrink-0 rounded-full object-cover"
/>
<span className="text-neutral-600">{task.assignee}</span>
</div>
</td>
<td className="px-4 py-3 text-neutral-500">{task.due}</td>
</tr>
);
})}
</tbody>
</table>
</div>
);
});
 
TasksTable.displayName = "TasksTable";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/table/tasks-table.tsx

Sponsor spot · demo preview

Logo

Your brand name

Your tagline or category

A short pitch about your product or service goes here. This is a preview of how sponsor cards will look in this sidebar.

Your call to action

This slot is available. Sponsor Opensource UI and reach developers browsing components every day.