I'm encountering an issue with my React-Bootstrap Table overflowing the viewport in the x-direction on smaller screens. I've tried making it responsive by using the responsive prop, but the overflow-x: scroll feature isn't functioning properly. How can I fix this overflow issue?
In my Typescript Vite project, the only file I've modified is App.tsx as shown below:
import { Table } from "react-bootstrap";
import "./App.css";
import "./styles.scss";
function App() {
return (
<div>
<span>Connected Devices:</span>
<Table
striped
bordered
hover
responsive
>
<thead>
<tr>
<th>IP Address</th>
<th>Protocol</th>
<th>Duration</th>
</tr>
</thead>
<tbody>
<tr>
<td>xxx.xxx.x.xx:xxxxx</td>
<td> ASCII</td>
<td>00:00:42</td>
</tr>
</tbody>
</Table>
</div>
);
}
export default App;
Additionally, I import the React-Bootstrap CSS using a styles.scss file:
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/variables-dark";
@import "../node_modules/bootstrap/scss/maps";
@import "../node_modules/bootstrap/scss/mixins";
@import "../node_modules/bootstrap/scss/utilities";
@import "../node_modules/bootstrap/scss/root";
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/grid";
@import "../node_modules/bootstrap/scss/tables";
@import "../node_modules/bootstrap/scss/forms";
@import "../node_modules/bootstrap/scss/buttons";
@import "../node_modules/bootstrap/scss/transitions";
@import "../node_modules/bootstrap/scss/nav";
@import "../node_modules/bootstrap/scss/navbar";
@import "../node_modules/bootstrap/scss/card";
@import "../node_modules/bootstrap/scss/list-group";
@import "../node_modules/bootstrap/scss/close";
@import "../node_modules/bootstrap/scss/toasts";
@import "../node_modules/bootstrap/scss/tooltip";
@import "../node_modules/bootstrap/scss/utilities/api";
When the screen width is smaller than the content, the issue can be seen in the screenshot below: https://i.sstatic.net/9nYfOdwK.png
The striped, bordered, and hover options are working correctly, except for the responsive one.
I've noticed that the selector added by this option uses the -webkit-overflow-scrolling property, which is no longer supported.
My bootstrap version is ^5.3.2 and react-bootstrap version is ^2.9.0, both being the latest versions available at the time of writing.