The Tr component provides a styled table row element for organizing table cells into rows. It's designed for consistent table row styling and proper spacing within table structures.
import { tr } from '@dashflowx/core'export default function TrExample() {return (<tr><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td></tr>)}
Preview:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | '' | Additional CSS classes |
import { tr } from '@dashflowx/core'export default function BasicTableRow() {return (<tr><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td></tr>)}
Preview:
import { tr } from '@dashflowx/core'export default function CustomStyledTableRow() {return (<tr className="border border-blue-500 rounded-lg p-4"><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td></tr>)}
Preview:
import { tr } from '@dashflowx/core'export default function TableRowWithData() {return (<tr><td>John Doe</td><td>john@example.com</td><td>Admin</td></tr>)}
Preview:
import { tr } from '@dashflowx/core'export default function TableRowWithActions() {return (<tr><td>John Doe</td><td>john@example.com</td><td>Admin</td><td><button>Edit</button><button>Delete</button></td></tr>)}
Preview:
import { tr } from '@dashflowx/core'export default function TableRowWithStatus() {return (<tr><td>John Doe</td><td>john@example.com</td><td>Admin</td><td><span className="px-2 py-1 text-xs bg-green-100 text-green-800 rounded">Active</span></td></tr>)}
Preview:
const dataTableRow = (<tr><td>Data 1</td><td>Data 2</td><td>Data 3</td></tr>);
const userTableRow = (<tr><td>John Doe</td><td>john@example.com</td><td>Admin</td></tr>);
const productTableRow = (<tr><td>Laptop</td><td>$999</td><td>25</td></tr>);
const orderTableRow = (<tr><td>#12345</td><td>John Doe</td><td>$99.99</td><td>Completed</td></tr>);
Maintain consistent styling across table rows.
// ✅ Good - Consistent styling<tr className="standard-row-style">Content</tr>// ❌ Avoid - Inconsistent styling<tr className="random-styles">Content</tr>
Ensure consistent cell count across rows.
// ✅ Good - Consistent cell count<tr><td>Cell 1</td><td>Cell 2</td><td>Cell 3</td></tr>// ❌ Avoid - Inconsistent cell count<tr><td>Cell 1</td><td>Cell 2</td></tr>
Ensure table rows are accessible to all users.
// ✅ Good - Accessible<tr>Content</tr>// ❌ Avoid - Not accessible<div>Row content</div>
Provide appropriate content for table rows.
// ✅ Good - Appropriate content<tr><td>Relevant data</td></tr>// ❌ Avoid - Inappropriate content<tr><td>Random text</td></tr>
Maintain consistent spacing across rows.
// ✅ Good - Consistent spacing<tr className="border-t">Content</tr>// ❌ Avoid - Inconsistent spacing<tr className="border-t-2">Content</tr>
You can customize the table row appearance using CSS classes:
<tr className="border border-gray-300 rounded-lg p-4" />
Use different themes for different contexts:
// Light theme<tr className="bg-white border-gray-200" />// Dark theme<tr className="bg-gray-900 border-gray-700 text-white" />// Brand theme<tr className="bg-blue-50 border-blue-200" />
Use different sizes for different emphasis levels:
// Small row<tr className="text-sm" />// Standard row<tr className="text-base" />// Large row<tr className="text-lg" />
Load row content dynamically:
const [rowContent, setRowContent] = useState([]);useEffect(() => {// Load content from APIloadRowContent().then(setRowContent);}, []);
Apply different styles based on conditions:
const getRowStyle = (status) => {if (status === 'active') {return 'bg-green-50';}return 'bg-red-50';};<tr className={getRowStyle(status)}><td>Content</td></tr>
Add actions to table rows:
<tr><td>John Doe</td><td>john@example.com</td><td><div className="flex space-x-2"><button>Edit</button><button>Delete</button></div></td></tr>
- Td: For table cells
- Th: For table headers
- Table: For table containers
- Button: For row actions
- Badge: For status indicators
For the complete API reference and advanced usage patterns, see the Tr API documentation.
