Todo Item
An interactive todo item with priority colors, due dates, labels, and subtask support.
Category
Micro InteractionReact
CSS
Tailwind
Manual
Create a file and paste the following code into it.
todo-item.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
"use client";
export type TodoPriority = "high" | "medium" | "low" | "none";
export interface TodoLabel {
id: string;
name: string;
color?: string;
}
export interface TodoSubtask {
id: string;
title: string;
completed: boolean;
}
export interface TodoProject {
id: string;
name: string;
color?: string;
}
export interface TodoItemProps {
id: string;
title: string;
description?: string;
completed: boolean;
priority: TodoPriority;
dueDate?: string | Date;
labels?: TodoLabel[];
subtasks?: TodoSubtask[];
project?: TodoProject;
onToggleComplete?: (id: string, completed: boolean) => void;
onClick?: (id: string) => void;
isSelected?: boolean;
className?: string;
}
export const priorityConfig = {
high: {
textColor: "text-red-500 dark:text-red-400",
bgColor: "bg-red-500/10 dark:bg-red-400/10",
borderColor: "border-red-500",
},
medium: {
textColor: "text-yellow-600 dark:text-yellow-400",
bgColor: "bg-yellow-500/10 dark:bg-yellow-400/10",
borderColor: "border-yellow-500",
},
low: {
textColor: "text-blue-500 dark:text-blue-400",
bgColor: "bg-sky-500/10 dark:bg-sky-400/10",
borderColor: "border-blue-500",
},
none: {
textColor: "text-zinc-500 dark:text-zinc-500",
bgColor: "bg-zinc-500/10 dark:bg-zinc-500/10",
borderColor: "border-zinc-400 dark:border-zinc-500",
},
} as const;
Update the import paths to match your project setup.