© Khmer Angkor Academy - sophearithput168

Tables

Bootstrap Tables (តារាង)

Bootstrap ធ្វើ​ឲ្យ tables ស្រស់ស្អាត​និង responsive។ Tables គឺ​ជា​មធ្យោបាយ​ល្អ​បំផុត​សម្រាប់​បង្ហាញ​ទិន្នន័យ​ជា​ជួរ​ឈរ និង ជួរ​ដេក។

🏗️ Table Structure & Components

Component HTML Tag Bootstrap Class Purpose
Table Container <table> .table តារាង​មូលដ្ឋាន - ទម្រង់​ទាំងអស់​ត្រូវការ class នេះ
Table Head <thead> .table-dark / .table-light ផ្នែក​ក្បាល​តារាង - មាន​ចំណងជើង​ជួរ​ឈរ
Table Body <tbody> - ផ្នែក​មាតិកា​តារាង - ទិន្នន័យ​ទាំងអស់
Table Row <tr> .table-{color} ជួរ​ដេក​នៃ​តារាង
Table Header Cell <th> - ក្រឡា​ចំណងជើង (bold, centered)
Table Data Cell <td> - ក្រឡា​ទិន្នន័យ​ធម្មតា
Table Footer <tfoot> - ផ្នែក​បាត​តារាង (optional) - សរុប​ឬ​សង្ខេប

🎨 Table Variants & Modifiers

Variant Class Visual Effect Use Case
.table-striped ជួរ​ឆ្លាស់​ពណ៌ (zebra stripes) តារាង​វែង​ដែល​ត្រូវការ​អាន​ងាយ - កាត់​បន្ថយ eye strain
.table-bordered ស៊ុម​ជុំវិញ​ក្រឡា​ទាំងអស់ តារាង​ដែល​ត្រូវការ​ភាព​ច្បាស់លាស់ - ទិន្នន័យ​សំខាន់
.table-borderless គ្មាន​ស៊ុម​សោះ តារាង​សាមញ្ញ - layout ស្អាត clean
.table-hover ពណ៌​ផ្សេង​ពេល​ hover ជួរ តារាង​អាច click បាន - បង្ហាញ interactivity
.table-dark ពណ៌​ងងឹត (dark theme) គេហទំព័រ​ពណ៌​ងងឹត - contrast ខ្ពស់
.table-sm padding តូច (compact) តារាង​ច្រើន​ជួរ - សន្សំ​កន្លែង

🌈 Table Row & Cell Colors

Color Class Background Color Semantic Meaning Example Use
.table-primary ពណ៌​ primary (blue) ទិន្នន័យ​សំខាន់ / highlighted Featured items, selected rows
.table-success ពណ៌​បៃតង (green) ជោគជ័យ / positive status Active users, completed tasks
.table-danger ពណ៌​ក្រហម (red) គ្រោះថ្នាក់ / error Inactive users, failed actions
.table-warning ពណ៌​លឿង (yellow) ព្រមាន / pending Pending approvals, warnings
.table-info ពណ៌​ផ្ទៃមេឃ (cyan) ព័ត៌មាន / informational Notes, additional information
.table-light ពណ៌​ស្រាល (light gray) Subtle highlight Header rows, separators
.table-dark ពណ៌​ងងឹត (dark gray) Strong contrast Header rows, footers

📱 Responsive Table Options

Wrapper Class Breakpoint Behavior When to Use
.table-responsive All sizes Horizontal scroll ពេល​តារាង​ទទឹង​ធំ​ពេក តារាង​ច្រើន​ជួរ​ឈរ - default choice
.table-responsive-sm < 576px Scroll លើ mobile តូច​តែ​ប៉ុណ្ណោះ តារាង​មធ្យម - OK on tablets+
.table-responsive-md < 768px Scroll លើ mobile និង tablet តូច តារាង​ធំ - OK on laptop+
.table-responsive-lg < 992px Scroll លើ tablet តារាង​ធំ​ពិសេស - desktop only
.table-responsive-xl < 1200px Scroll លើ laptop តូច តារាង​ធំ​ខ្លាំង - large screens
.table-responsive-xxl < 1400px Scroll លើ​អេក្រង់​ធម្មតា តារាង​ធំ​ណាស់ - ultra-wide screens

📏 Table Sizing

Aspect Class/Attribute Effect
Compact Table .table-sm Padding តូច (0.3rem instead of 0.5rem)
Column Width style="width: 200px" on <th> កំណត់​ទទឹង​ជួរ​ឈរ​ជាក់លាក់
Vertical Alignment .align-top, .align-middle, .align-bottom តម្រឹម​មាតិកា​បញ្ឈរ​ក្នុង​ក្រឡា

🎯 Common Table Patterns

Pattern Classes Combination Purpose
Data Table .table .table-striped .table-hover តារាង​ទិន្នន័យ​អាច​អាន និង click បាន
Clean Table .table .table-borderless តារាង​សាមញ្ញ​គ្មាន​ស៊ុម
Compact Data .table .table-sm .table-bordered តារាង​ច្រើន​ទិន្នន័យ​ក្នុង​កន្លែង​តូច
Dashboard Table .table .table-hover + colored rows តារាង status dashboard
Report Table .table .table-bordered .table-striped + dark header របាយការណ៍​ផ្លូវការ - professional look

✅ Table Best Practices

❌ Avoid ✅ Best Practice
Forgetting .table-responsive wrapper for wide tables Always wrap tables >5 columns with <div class="table-responsive">
Using too many colors randomly Use semantic colors purposefully (success=active, danger=error)
Very long tables without pagination Limit to 10-20 rows per page with pagination component
Combining too many variants (.striped + .bordered + .hover + .dark) Keep it simple - 2-3 variants maximum
Not using <thead> and <tbody> Always use semantic HTML structure for accessibility
Fixed column widths that break responsive Let columns auto-size or use percentage widths
No header labels for data columns Clear, concise <th> labels for every column

Table Variants & Responsive