| 1 |
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table'; |
| 2 |
|
| 3 |
// This example has been simplified to focus on the text modifier props. In real usage, |
| 4 |
// you may want to derive your rows from typed underlying data and minimal state. See other examples. |
| 5 |
|
| 6 |
const columnNames = { |
| 7 |
truncate: 'Truncate (width 20%)', |
| 8 |
break: 'Break word', |
| 9 |
wrap: 'Wrapping table header text. This th text will wrap instead of truncate.', |
| 10 |
fit: 'Fit content', |
| 11 |
nowrap: 'No wrap' |
| 12 |
}; |
| 13 |
|
| 14 |
export const TableControllingText: React.FunctionComponent = () => ( |
| 15 |
<Table aria-label="Controlling text"> |
| 16 |
<Thead> |
| 17 |
<Tr> |
| 18 |
<Th width={20}>{columnNames.truncate}</Th> |
| 19 |
<Th>{columnNames.break}</Th> |
| 20 |
<Th modifier="wrap">{columnNames.wrap}</Th> |
| 21 |
<Th modifier="fitContent">{columnNames.fit}</Th> |
| 22 |
<Th>{columnNames.nowrap}</Th> |
| 23 |
</Tr> |
| 24 |
</Thead> |
| 25 |
<Tbody> |
| 26 |
<Tr> |
| 27 |
<Td dataLabel={columnNames.truncate} modifier="truncate"> |
| 28 |
This text will truncate instead of wrap. |
| 29 |
</Td> |
| 30 |
<Td dataLabel={columnNames.break} modifier="breakWord"> |
| 31 |
<a>http://thisisaverylongurlthatneedstobreakusethebreakwordmodifier.org</a> |
| 32 |
</Td> |
| 33 |
<Td dataLabel={columnNames.wrap}> |
| 34 |
<p> |
| 35 |
By default, |
| 36 |
<code>thead</code> cells will truncate and |
| 37 |
<code>tbody</code> cells will wrap. Use |
| 38 |
<code>.pf-m-wrap</code> on a<code>th</code> to change its behavior. |
| 39 |
</p> |
| 40 |
</Td> |
| 41 |
<Td dataLabel={columnNames.fit}> |
| 42 |
This cell's content will adjust itself to the parent th width. This modifier only affects table layouts. |
| 43 |
</Td> |
| 44 |
<Td dataLabel={columnNames.nowrap} modifier="nowrap"> |
| 45 |
<a href="#">No wrap</a> |
| 46 |
</Td> |
| 47 |
</Tr> |
| 48 |
</Tbody> |
| 49 |
</Table> |
| 50 |
); |