import { Fragment } from 'react'; import { Table, Caption, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table'; interface Repository { name: string; branches: number; description?: string; prs: number; workspaces: number; lastCommit: string; } export const TableStripedMultipleTbody: React.FunctionComponent = () => { // In real usage, this data would come from some external source like an API via props. const repositories1: Repository[] = [ { name: 'tbody 1 - Repository 1', description: '(odd rows striped)', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' }, { name: 'tbody 1 - Repository 2', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' }, { name: 'tbody 1 - Repository 3', description: '(odd rows striped)', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' } ]; const repositories2: Repository[] = [ { name: 'tbody 2 - Repository 4', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' }, { name: 'tbody 2 - Repository 5', description: '(even rows striped)', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' }, { name: 'tbody 2 - Repository 6', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' }, { name: 'tbody 2 - Repository 7', description: '(even rows striped)', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' } ]; const columnNames = { name: 'Repositories', branches: 'Branches', prs: 'Pull requests', workspaces: 'Workspaces', lastCommit: 'Last commit' }; return ( {repositories1.map((repo) => ( ))} {repositories2.map((repo) => ( ))}
Striped table using multiple tbody components
{columnNames.name} {columnNames.branches} {columnNames.prs} {columnNames.workspaces} {columnNames.lastCommit}
{repo.description ? ( {repo.name}
{repo.description}
) : ( repo.name )}
{repo.branches} {repo.prs} {repo.workspaces} {repo.lastCommit}
{repo.description ? ( {repo.name}
{repo.description}
) : ( repo.name )}
{repo.branches} {repo.prs} {repo.workspaces} {repo.lastCommit}
); };