UNPKG

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