JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<thead>
<tr>
<th>#</th>
<th>Todo</th>
<th>Options</th>
</tr>
</thead>
<tbody></tbody>
</table>
CSS
body{
margin: 0px;
padding: 1rem;
box-sizing: border-box;
background: #f7f7f7;
height: 100ssvh;
height: 100sdvh;
height: 100svh;
}
table{
border-collapse: collapse;
background: #fff;
width: 100%;
box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
}
table thead{}
table thead th{padding: 2rem;}
table thead th:nth-child(1){border-right: 1px solid red;}
table thead tr th{border-bottom: 1px solid blue;}
table tbody{}
table tbody tr{}
table tbody tr td{
padding: 1rem;
border-bottom: 1px solid blue;
}
table tbody tr td:nth-child(1){
border-right: 1px solid red;
width: 40px;
text-align: right;
}
table tbody tr td:nth-child(3){text-align: right;}
JavaScript
let todo_list = [
{text: 'hello world', date: ''},
];
function add_item(){
event.preventDefault();
let input = event.target.querySelector('input');
todo_list.push({
text: input.value,
date: new Date().toJSON(),
});
render(todo_list);
}
function delete_item(index){
todo_list = todo_list.splice(index, 1);
render(todo_list);
}
function render(todo_list = []){
let tbody = document.querySelector('table tbody');
tbody.innerHTML = todo_list.map((item, itemNumber)=>{
return `
<tr>
<td>${itemNumber + 1}</td>
<td>${item.text}</td>
<td><button onclick="delete_item(${itemNumber})">Delete</button></td>
</tr>`
}).join('');
tbody.innerHTML+= `
<tr>
<td></td>
<td>
<form onsubmit="add_item()">
<input>
</form>
</td>
<td><button type="submit">Add</button></td>
</tr>
`;
}
render(todo_list);