The Td component provides a styled table cell element for displaying data in table rows. It's designed for consistent table cell styling and proper alignment within table structures.
import { td } from '@dashflowx/core'export default function TdExample() {return (<td>Cell content</td>)}
Preview:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | '' | Additional CSS classes |
import { td } from '@dashflowx/core'export default function BasicTableCell() {return (<td>Cell content</td>)}
Preview:
import { td } from '@dashflowx/core'export default function CustomStyledTableCell() {return (<td className="border border-blue-500 rounded-lg p-4">Custom styled cell</td>)}
Preview:
import { td } from '@dashflowx/core'export default function TableCellWithData() {return (<td>John Doe</td>)}
Preview:
import { td } from '@dashflowx/core'export default function TableCellWithNumber() {return (<td>25</td>)}
Preview:
import { td } from '@dashflowx/core'export default function TableCellWithStatus() {return (<td><span className="px-2 py-1 text-xs bg-green-100 text-green-800 rounded">Active</span></td>)}
Preview:
const dataTableCell = (<td>Data value</td>);
const userInfoCell = (<td>john@example.com</td>);
const statusCell = (<td><span className="status-badge">Active</span></td>);
const actionCell = (<td><button>Edit</button><button>Delete</button></td>);
Maintain consistent styling across table cells.
// ✅ Good - Consistent styling<td className="standard-cell-style">Content</td>// ❌ Avoid - Inconsistent styling<td className="random-styles">Content</td>
Use appropriate alignment for different data types.
// ✅ Good - Proper alignment<td className="text-right">$100.00</td> // Numbers<td className="text-left">John Doe</td> // Text// ❌ Avoid - Poor alignment<td>$100.00</td><td>John Doe</td>
Ensure table cell content is accessible.
// ✅ Good - Accessible<td>Clear content</td>// ❌ Avoid - Not accessible<td></td>
Provide appropriate content for table cells.
// ✅ Good - Appropriate content<td>Relevant data</td>// ❌ Avoid - Inappropriate content<td>Random text</td>
Maintain consistent padding across cells.
// ✅ Good - Consistent padding<td className="p-4">Content</td>// ❌ Avoid - Inconsistent padding<td className="p-2">Content</td>
You can customize the table cell appearance using CSS classes:
<td className="border border-gray-300 rounded-lg p-4" />
Use different themes for different contexts:
// Light theme<td className="bg-white border-gray-200" />// Dark theme<td className="bg-gray-900 border-gray-700 text-white" />// Brand theme<td className="bg-blue-50 border-blue-200" />
Use different sizes for different emphasis levels:
// Small cell<td className="text-sm p-2" />// Standard cell<td className="text-base p-4" />// Large cell<td className="text-lg p-6" />
Load cell content dynamically:
const [cellContent, setCellContent] = useState('');useEffect(() => {// Load content from APIloadCellContent().then(setCellContent);}, []);
Show different content based on conditions:
const getCellContent = (status) => {if (status === 'active') {return <span className="text-green-600">Active</span>;}return <span className="text-red-600">Inactive</span>;};
Add actions to table cells:
<td><div className="flex space-x-2"><button>Edit</button><button>Delete</button></div></td>
- Th: For table headers
- Tr: For table rows
- Table: For table containers
- Button: For cell actions
- Badge: For status indicators
For the complete API reference and advanced usage patterns, see the Td API documentation.
