I want to make a table similar to gmail inbox table in which the table columns are diaplayed as rows on small screens. I am using Ant Design's table component but I can't find how to make it responsive in the documentation.
What I want on big screens:
| From | To |
|---|---|
| aaa@example.com | zzz.zzz@example.com |
| ccc@example.com | yyy.yyy@example.com |
What I want on small screens:
| From To |
|---|
| aaa@example.com zzz.zzz@example.com |
| ccc@example.com yyy.yyy@example.com |
This is my react code in which I have made a tabl using Ant Design:
import "./App.css";
import { Table } from "antd";
function App() {
const columns = [
{
title: "From",
dataIndex: "from",
sorter: (a, b) => a.from.length - b.from.length,
sortDirections: ["descend", "ascend"],
},
{
title: "To",
dataIndex: "to",
sorter: (a, b) => a.to - b.to,
sortDirections: ["descend", "ascend"],
},
{
title: "Subject",
dataIndex: "subject",
sorter: (a, b) => a.subject.length - b.subject.length,
sortDirections: ["descend", "ascend"],
},
{
title: "Date",
dataIndex: "date",
sorter: (a, b) => a.date.length - b.date.length,
sortDirections: ["descend", "ascend"],
},
];
const data = [
{
key: "1",
from: "aaa@example.com",
to: "zzz.zzz@example.com",
subject: "[ HR-888 ] Notice of official announcement",
date: "0:20",
},
{
key: "2",
from: "bbb.bbbb@example.com",
to: "yyy.yyy@example.com",
subject: `[web:333] "Web Contact"`,
date: "0:20",
}
];
return (
<div className="App">
<Table columns={columns} dataSource={data} pagination={false} />
</div>
);
}
export default App;