JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.js"></script>
</head>
<body>
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Uvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevweuvuvwevwevwe Onyetenyevwe Ugwemuhwem Osas</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
</tbody>
</table>
</body>
<script>
$(document).ready(function () {
...
CSS
table{
table-layout: fixed;
}
td {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
JavaScript
/**
* This data rendering helper method can be useful for cases where you have
* potentially large data strings to be shown in a column that is restricted by
* width. The data for the column is still fully searchable and sortable, but if
* it is longer than a give number of characters, it will be truncated and
* shown with ellipsis. A browser provided tooltip will show the full string
* to the end user on mouse hover of the cell.
*
* This function should be used with the `dt-init columns.render` configuration
* option of DataTables.
*
* It accepts three parameters:
*
* 1. `-type integer` - The number of characters to restrict the displayed data
* to.
* 2. `-type boolean` (optional - default `false`) - Indicate if the truncation
* of the string should not occur in the middle of a word (`true`) or if it
* can (`false`). This can allow the display of strings to look nicer, at the
* expense of showing less characters.
* 2. `-type boolean` (optional - default `false`) - Escape HTML entities
* (`true`) or not (`false` - default).
*
* @name ellipsis
* @summary Restrict output data to a particular length, showing anything
* longer with ellipsis and a browser provided tooltip on hover.
* @author [Allan Jardine](http://datatables.net)
* @requires DataTables 1.10+
*
* @returns {Number} Calculated average
*
* @example
* // Restrict a column to 17 characters, don't split words
* $('#example').DataTable( {
* columnDefs: [ {
* targets: 1,
* render: $.fn.dataTable.render.ellipsis( 17, true )
* } ]
* } );
*
* @example
* // Restrict a column to 10 characters, do split words
* $('#example').DataTable( {
* columnDefs: [ {
* targets: 2,
* render: $.fn.dataTable.render.ellipsis( 10 )
* } ]
* } );
*/
jQuery.fn.dataTable.render.ellipsis = function (cutoff, wordbreak, escapeHtml) {
var esc = function (t) {
return t
...