{"id":3918,"date":"2022-10-22T05:23:53","date_gmt":"2022-10-22T05:23:53","guid":{"rendered":"https:\/\/rengga.dev\/blog\/?p=3918"},"modified":"2023-06-10T11:34:39","modified_gmt":"2023-06-10T11:34:39","slug":"tailwind-css-responsive-table","status":"publish","type":"post","link":"https:\/\/rengga.dev\/blog\/tailwind-css-responsive-table\/","title":{"rendered":"Tailwind &#8211; CSS Responsive Table"},"content":{"rendered":"<p>Tailwind CSS is a popular utility-first CSS framework that provides a set of pre-designed CSS classes to help you quickly build responsive and customizable user interfaces. One of the common UI components that you might need to build is a responsive table, which can be tricky to style and make it work well on different devices.<\/p>\n<p>Tailwind CSS provides pre-designed classes to help you build responsive tables easily. These classes allow you to style the table header, body, and cells, as well as handle table layout and alignment. With Tailwind CSS, you can easily create a responsive table that looks great on any device and screen size.<\/p>\n<p>For example, to create a basic responsive table using Tailwind CSS, you can use the following HTML code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;div class=\"overflow-x-auto\"&gt;\r\n  &lt;table class=\"table w-full\"&gt;\r\n    &lt;thead&gt;\r\n      &lt;tr&gt;\r\n        &lt;th class=\"px-4 py-2\"&gt;Name&lt;\/th&gt;\r\n        &lt;th class=\"px-4 py-2\"&gt;Age&lt;\/th&gt;\r\n        &lt;th class=\"px-4 py-2\"&gt;Email&lt;\/th&gt;\r\n      &lt;\/tr&gt;\r\n    &lt;\/thead&gt;\r\n    &lt;tbody&gt;\r\n      &lt;tr&gt;\r\n        &lt;td class=\"border px-4 py-2\"&gt;John Doe&lt;\/td&gt;\r\n        &lt;td class=\"border px-4 py-2\"&gt;35&lt;\/td&gt;\r\n        &lt;td class=\"border px-4 py-2\"&gt;john@example.com&lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n      &lt;tr&gt;\r\n        &lt;td class=\"border px-4 py-2\"&gt;Jane Doe&lt;\/td&gt;\r\n        &lt;td class=\"border px-4 py-2\"&gt;28&lt;\/td&gt;\r\n        &lt;td class=\"border px-4 py-2\"&gt;jane@example.com&lt;\/td&gt;\r\n      &lt;\/tr&gt;\r\n    &lt;\/tbody&gt;\r\n  &lt;\/table&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>In this example, the <code>table<\/code> class is used to define the table, while the <code>thead<\/code>, <code>tbody<\/code>, <code>th<\/code>, and <code>td<\/code> elements are used to define the table structure. The <code>px-4<\/code> and <code>py-2<\/code> classes are used to set the padding of the cells, while the <code>border<\/code> class is used to add a border to the cells.<\/p>\n<p>The <code>overflow-x-auto<\/code> class is used to enable horizontal scrolling on small screens when the table width exceeds the screen size.<\/p>\n<p>Overall, Tailwind CSS makes it easy to build responsive tables that look great on any device and screen size.<\/p>\n<div class=\"su-row\">\n<div class=\"su-column su-column-size-1-2\"><div class=\"su-column-inner su-u-clearfix su-u-trim\">\n<div class=\"su-button-center\"><a href=\"https:\/\/www.tailwindtoolbox.com\/components\/responsive-table-demo.php\" class=\"su-button su-button-style-glass su-button-wide\" style=\"color:#FFFFFF;background-color:#a70d33;border-color:#860b29;border-radius:50px\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"color:#FFFFFF;padding:8px 24px;font-size:18px;line-height:27px;border-color:#c25671;border-radius:50px;text-shadow:1px 1px 1px #000000\"><i class=\"sui sui-globe-w\" style=\"font-size:18px;color:#FFFFFF\"><\/i> Demo Page<\/span><\/a><\/div>\n<\/div><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Tailwind CSS is a popular utility-first CSS framework that provides a set <a class=\"read-more\" href=\"https:\/\/rengga.dev\/blog\/tailwind-css-responsive-table\/\" title=\"Tailwind &#8211; CSS Responsive Table\" itemprop=\"url\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":3919,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,20],"tags":[239,475,472,474,103,392],"newstopic":[],"class_list":{"0":"post-3918","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-html-css","8":"category-javascript","9":"tag-chart-js","10":"tag-css-responsive-table","11":"tag-tailwind-css","12":"tag-tailwind-tutorial","13":"tag-web-design","14":"tag-web-design-2023"},"_links":{"self":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3918","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/comments?post=3918"}],"version-history":[{"count":2,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3918\/revisions"}],"predecessor-version":[{"id":3921,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/posts\/3918\/revisions\/3921"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media\/3919"}],"wp:attachment":[{"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/media?parent=3918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/categories?post=3918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/tags?post=3918"},{"taxonomy":"newstopic","embeddable":true,"href":"https:\/\/rengga.dev\/blog\/wp-json\/wp\/v2\/newstopic?post=3918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}