UNPKG

2.41 kBTypeScriptView Raw
1import * as React from 'react';
2import { StandardProps } from '..';
3import { Padding, Size } from '../Table';
4
5export { Padding, Size };
6
7/**
8 * `<TableCell>` will be rendered as an `<th>`or `<td>` depending
9 * on the context it is used in. Where context literally is the
10 * React `context`.
11 *
12 * Since it is not decided via prop, we have create loose typings
13 * here.
14 */
15export interface TableCellProps
16 extends StandardProps<TableCellBaseProps, TableCellClassKey, 'align'> {
17 /**
18 * Set the text-align on the table cell content.
19 *
20 * Monetary or generally number fields **should be right aligned** as that allows
21 * you to add them up quickly in your head without having to worry about decimals.
22 */
23 align?: 'inherit' | 'left' | 'center' | 'right' | 'justify';
24 /**
25 * The table cell contents.
26 */
27 children?: React.ReactNode;
28 /**
29 * The component used for the root node.
30 * Either a string to use a HTML element or a component.
31 */
32 component?: React.ElementType<TableCellBaseProps>;
33 /**
34 * Sets the padding applied to the cell.
35 * By default, the Table parent component set the value (`normal`).
36 * `default` is deprecated, use `normal` instead.
37 */
38 padding?: Padding;
39 /**
40 * Set scope attribute.
41 */
42 scope?: TableCellBaseProps['scope'];
43 /**
44 * Specify the size of the cell.
45 * By default, the Table parent component set the value (`medium`).
46 */
47 size?: Size;
48 /**
49 * Set aria-sort direction.
50 */
51 sortDirection?: SortDirection;
52 /**
53 * Specify the cell type.
54 * By default, the TableHead, TableBody or TableFooter parent component set the value.
55 */
56 variant?: 'head' | 'body' | 'footer';
57}
58
59export type TableCellBaseProps = React.ThHTMLAttributes<HTMLTableHeaderCellElement> &
60 React.TdHTMLAttributes<HTMLTableDataCellElement>;
61
62export type SortDirection = 'asc' | 'desc' | false;
63
64export type TableCellClassKey =
65 | 'root'
66 | 'head'
67 | 'body'
68 | 'footer'
69 | 'alignLeft'
70 | 'alignCenter'
71 | 'alignRight'
72 | 'alignJustify'
73 | 'sizeSmall'
74 | 'paddingCheckbox'
75 | 'paddingNone'
76 | 'stickyHeader';
77
78/**
79 * The component renders a `<th>` element when the parent context is a header
80 * or otherwise a `<td>` element.
81 * Demos:
82 *
83 * - [Tables](https://mui.com/components/tables/)
84 *
85 * API:
86 *
87 * - [TableCell API](https://mui.com/api/table-cell/)
88 */
89export default function TableCell(props: TableCellProps): JSX.Element;