xref: /expo/docs/ui/components/Table/Cell.tsx (revision bfa66871)
1import { css } from '@emotion/react';
2import { spacing, theme } from '@expo/styleguide';
3import React, { PropsWithChildren } from 'react';
4
5import { TextAlign } from './types';
6
7type CellProps = PropsWithChildren<{
8  fitContent?: boolean;
9  textAlign?: TextAlign;
10}>;
11
12export const Cell = ({ children, fitContent = false, textAlign = TextAlign.Left }: CellProps) => (
13  <td css={[tableCellStyle, { textAlign }, fitContent && fitContentStyle]}>{children}</td>
14);
15
16const tableCellStyle = css({
17  padding: spacing[4],
18  verticalAlign: 'middle',
19  borderRight: `1px solid ${theme.border.default}`,
20
21  '&:last-child': {
22    borderRight: 0,
23  },
24});
25
26const fitContentStyle = css({
27  width: 'fit-content',
28});
29