# Sheet

## Introduction

Sheet is a foundational surface component that serves as a container for grouping and visually separating content. It acts as the building block for creating cards, panels, dialogs, and other elevated UI elements. By combining different `variant` and `color` props, you can tailor the Sheet's appearance to match its purpose -- whether it is a subtle content container, an attention-grabbing notification banner, or a structured form wrapper.

Sheet is built on top of Joy UI's Sheet component and inherits all of its styling capabilities, including support for the `sx` prop for custom styling, responsive design tokens, and Framer Motion animation props.

```tsx
<Sheet
    {...args}
    sx={{
      p: 3,
      maxWidth: 400,
      borderRadius: "md"
    }}
  >
    <Typography
      level="title-md"
      sx={{
        mb: 2
      }}
    >
      Sheet 컴포넌트
    </Typography>
    <Typography level="body-md">
      이것은 Sheet 컴포넌트의 기본 예제입니다. 다양한 콘텐츠를 담을 수 있는 표면을 제공합니다.
    </Typography>
  </Sheet>
```

| Field   | Description | Default    |
| ------- | ----------- | ---------- |
| variant | 시트 스타일 변형   | "outlined" |
| color   | 시트 색상       | "neutral"  |

## Usage

```tsx
import { Sheet } from '@ceed/cds';

function MyComponent() {
  return (
    <Sheet variant="outlined" sx={{ p: 3, borderRadius: 'md' }}>
      <Typography level="title-md">Sheet Title</Typography>
      <Typography level="body-md">Content goes inside the sheet.</Typography>
    </Sheet>
  );
}
```

## Variants

Sheet supports four visual variants to convey different levels of emphasis.

```tsx
<div
    style={{
      display: "flex",
      gap: "2rem",
      flexWrap: "wrap"
    }}
  >
    <Sheet
      variant="solid"
      sx={{
        p: 3,
        maxWidth: 250,
        borderRadius: "md"
      }}
    >
      <Typography
        level="title-md"
        sx={{
          mb: 1,
          color: "white"
        }}
      >
        Solid
      </Typography>
      <Typography
        level="body-sm"
        sx={{
          color: "white"
        }}
      >
        배경이 채워진 스타일
      </Typography>
    </Sheet>

    <Sheet
      variant="soft"
      sx={{
        p: 3,
        maxWidth: 250,
        borderRadius: "md"
      }}
    >
      <Typography
        level="title-md"
        sx={{
          mb: 1
        }}
      >
        Soft
      </Typography>
      <Typography level="body-sm">부드러운 배경 스타일</Typography>
    </Sheet>

    <Sheet
      variant="outlined"
      sx={{
        p: 3,
        maxWidth: 250,
        borderRadius: "md"
      }}
    >
      <Typography
        level="title-md"
        sx={{
          mb: 1
        }}
      >
        Outlined
      </Typography>
      <Typography level="body-sm">테두리가 있는 스타일</Typography>
    </Sheet>

    <Sheet
      variant="plain"
      sx={{
        p: 3,
        maxWidth: 250,
        borderRadius: "md"
      }}
    >
      <Typography
        level="title-md"
        sx={{
          mb: 1
        }}
      >
        Plain
      </Typography>
      <Typography level="body-sm">배경이 없는 평면 스타일</Typography>
    </Sheet>
  </div>
```

## Colors

Apply semantic colors to communicate meaning -- use `danger` for errors, `success` for confirmations, `warning` for alerts, and `primary` for highlighted content.

```tsx
<div
    style={{
      display: "flex",
      gap: "1rem",
      flexWrap: "wrap"
    }}
  >
    <Sheet
      color="primary"
      variant="soft"
      sx={{
        p: 2,
        borderRadius: "md"
      }}
    >
      <Typography level="title-sm">Primary</Typography>
    </Sheet>

    <Sheet
      color="neutral"
      variant="soft"
      sx={{
        p: 2,
        borderRadius: "md"
      }}
    >
      <Typography level="title-sm">Neutral</Typography>
    </Sheet>

    <Sheet
      color="danger"
      variant="soft"
      sx={{
        p: 2,
        borderRadius: "md"
      }}
    >
      <Typography level="title-sm">Danger</Typography>
    </Sheet>

    <Sheet
      color="success"
      variant="soft"
      sx={{
        p: 2,
        borderRadius: "md"
      }}
    >
      <Typography level="title-sm">Success</Typography>
    </Sheet>

    <Sheet
      color="warning"
      variant="soft"
      sx={{
        p: 2,
        borderRadius: "md"
      }}
    >
      <Typography level="title-sm">Warning</Typography>
    </Sheet>
  </div>
```

## Basic

The simplest form of a Sheet with minimal configuration.

```tsx
<div
    style={{
      display: "flex",
      gap: "2rem",
      flexWrap: "wrap"
    }}
  >
    <Sheet
      sx={{
        p: 3,
        maxWidth: 300,
        borderRadius: "md"
      }}
    >
      <Typography
        level="title-md"
        sx={{
          mb: 1
        }}
      >
        기본 Sheet
      </Typography>
      <Typography level="body-sm">가장 기본적인 Sheet 컴포넌트입니다.</Typography>
    </Sheet>

    <Sheet
      variant="outlined"
      sx={{
        p: 3,
        maxWidth: 300,
        borderRadius: "md"
      }}
    >
      <Typography
        level="title-md"
        sx={{
          mb: 1
        }}
      >
        Outlined Sheet
      </Typography>
      <Typography level="body-sm">테두리가 있는 Sheet 컴포넌트입니다.</Typography>
    </Sheet>
  </div>
```

## User Profile Card

Sheet can be composed with other components to create rich profile cards.

```tsx
<Sheet
    variant="outlined"
    sx={{
      maxWidth: 400,
      borderRadius: "lg",
      p: 3
    }}
  >
    <Stack spacing={3}>
      <Stack direction="row" spacing={2} alignItems="center">
        <Avatar size="lg" src="https://i.pravatar.cc/100?img=1" />
        <Stack spacing={0.5}>
          <Typography level="title-lg">김철수</Typography>
          <Typography
            level="body-sm"
            sx={{
              color: "text.secondary"
            }}
          >
            프론트엔드 개발자
          </Typography>
        </Stack>
        <Box
          sx={{
            ml: "auto"
          }}
        >
          <IconButton variant="plain" size="sm">
            <SettingsIcon />
          </IconButton>
        </Box>
      </Stack>

      <Typography level="body-md">
        사용자 경험을 중시하는 프론트엔드 개발자입니다. React와 TypeScript를 주로 사용하며, 깔끔하고
        직관적인 인터페이스 구현에 관심이 많습니다.
      </Typography>

      <Stack direction="row" spacing={1}>
        <Chip size="sm" variant="soft">
          React
        </Chip>
        <Chip size="sm" variant="soft">
          TypeScript
        </Chip>
        <Chip size="sm" variant="soft">
          Next.js
        </Chip>
      </Stack>

      <Stack direction="row" spacing={2}>
        <Button variant="outlined" fullWidth>
          팔로우
        </Button>
        <Button fullWidth>메시지 보내기</Button>
      </Stack>
    </Stack>
  </Sheet>
```

## Article Card

Combine Sheet with images, chips, and actions for article-style layouts.

```tsx
<Sheet
    variant="outlined"
    sx={{
      maxWidth: 500,
      borderRadius: "lg",
      overflow: "hidden"
    }}
  >
    <Box
      sx={{
        height: 200,
        bgcolor: "neutral.100",
        backgroundImage:
          "url(https://images.unsplash.com/photo-1486312338219-ce68d2c6f44d?ixlib=rb-4.0.3&auto=format&fit=crop&w=500&q=80)",
        backgroundSize: "cover",
        backgroundPosition: "center"
      }}
    />

    <Stack
      spacing={2}
      sx={{
        p: 3
      }}
    >
      <Stack direction="row" justifyContent="space-between" alignItems="flex-start">
        <Stack spacing={1}>
          <Typography level="title-lg">React 18의 새로운 기능들</Typography>
          <Typography
            level="body-sm"
            sx={{
              color: "text.secondary"
            }}
          >
            2024년 1월 15일 • 5분 읽기
          </Typography>
        </Stack>
        <IconButton
          variant="plain"
          size="sm"
          sx={{
            color: "warning.500"
          }}
        >
          <StarIcon />
        </IconButton>
      </Stack>

      <Typography level="body-md">
        React 18에서 도입된 Concurrent Features와 새로운 Hooks에 대해 자세히 알아보겠습니다.
        Suspense, useTransition, useDeferredValue 등의 새로운 기능들이 어떻게 사용자 경험을
        개선하는지 살펴보겠습니다.
      </Typography>

      <Stack direction="row" spacing={1}>
        <Chip size="sm" variant="outlined">
          React
        </Chip>
        <Chip size="sm" variant="outlined">
          JavaScript
        </Chip>
        <Chip size="sm" variant="outlined">
          개발
        </Chip>
      </Stack>

      <Stack direction="row" justifyContent="space-between" alignItems="center">
        <Stack direction="row" spacing={1} alignItems="center">
          <Avatar size="sm" src="https://i.pravatar.cc/32?img=2" />
          <Typography level="body-sm">김개발</Typography>
        </Stack>

        <Stack direction="row" spacing={1}>
          <Button size="sm" variant="plain" startDecorator={<FavoriteIcon />}>
            24
          </Button>
          <Button size="sm" variant="plain" startDecorator={<ShareIcon />}>
            공유
          </Button>
        </Stack>
      </Stack>
    </Stack>
  </Sheet>
```

## Notification Panel

Use `variant="soft"` with a semantic color to create attention-grabbing notification banners.

```tsx
<Sheet
    variant="soft"
    color="primary"
    sx={{
      maxWidth: 400,
      borderRadius: "lg",
      p: 3
    }}
  >
    <Stack direction="row" justifyContent="space-between" alignItems="flex-start" spacing={2}>
      <Stack spacing={1}>
        <Typography level="title-md">새로운 알림이 있습니다</Typography>
        <Typography level="body-sm">
          프로젝트에 새로운 댓글이 달렸습니다. 확인해보시겠습니까?
        </Typography>
      </Stack>
      <IconButton variant="plain" size="sm">
        <CloseIcon />
      </IconButton>
    </Stack>

    <Stack
      direction="row"
      spacing={2}
      sx={{
        mt: 3
      }}
    >
      <Button size="sm" variant="solid">
        확인하기
      </Button>
      <Button size="sm" variant="outlined">
        나중에
      </Button>
    </Stack>
  </Sheet>
```

## Stats Cards

Multiple Sheet instances arranged side by side make effective dashboard stat widgets.

```tsx
<div
    style={{
      display: "flex",
      gap: "1rem",
      flexWrap: "wrap"
    }}
  >
    <Sheet
      variant="outlined"
      sx={{
        minWidth: 200,
        borderRadius: "lg",
        p: 3
      }}
    >
      <Stack spacing={1}>
        <Typography
          level="body-sm"
          sx={{
            color: "text.secondary"
          }}
        >
          총 사용자
        </Typography>
        <Typography level="h2" color="primary">
          1,234
        </Typography>
        <Typography
          level="body-xs"
          sx={{
            color: "success.600"
          }}
        >
          +12% 증가
        </Typography>
      </Stack>
    </Sheet>

    <Sheet
      variant="outlined"
      sx={{
        minWidth: 200,
        borderRadius: "lg",
        p: 3
      }}
    >
      <Stack spacing={1}>
        <Typography
          level="body-sm"
          sx={{
            color: "text.secondary"
          }}
        >
          매출
        </Typography>
        <Typography level="h2" color="primary">
          ₩5.6M
        </Typography>
        <Typography
          level="body-xs"
          sx={{
            color: "success.600"
          }}
        >
          +8% 증가
        </Typography>
      </Stack>
    </Sheet>

    <Sheet
      variant="outlined"
      sx={{
        minWidth: 200,
        borderRadius: "lg",
        p: 3
      }}
    >
      <Stack spacing={1}>
        <Typography
          level="body-sm"
          sx={{
            color: "text.secondary"
          }}
        >
          주문 수
        </Typography>
        <Typography level="h2" color="primary">
          789
        </Typography>
        <Typography
          level="body-xs"
          sx={{
            color: "danger.600"
          }}
        >
          -3% 감소
        </Typography>
      </Stack>
    </Sheet>
  </div>
```

## Form Sheet

Wrap form elements inside a Sheet to create visually contained form sections.

```tsx
<Sheet
    variant="outlined"
    sx={{
      maxWidth: 400,
      borderRadius: "lg",
      p: 4
    }}
  >
    <Stack spacing={3}>
      <Stack spacing={1}>
        <Typography level="title-lg">문의하기</Typography>
        <Typography
          level="body-sm"
          sx={{
            color: "text.secondary"
          }}
        >
          궁금한 점이 있으시면 언제든지 연락해 주세요.
        </Typography>
      </Stack>

      <Stack spacing={2}>
        <Stack spacing={1}>
          <Typography level="body-sm" fontWeight="500">
            이름
          </Typography>
          <Box
            sx={{
              p: 2,
              border: "1px solid",
              borderColor: "divider",
              borderRadius: "sm",
              bgcolor: "background.level1"
            }}
          >
            <Typography
              level="body-sm"
              sx={{
                color: "text.secondary"
              }}
            >
              이름을 입력하세요
            </Typography>
          </Box>
        </Stack>

        <Stack spacing={1}>
          <Typography level="body-sm" fontWeight="500">
            이메일
          </Typography>
          <Box
            sx={{
              p: 2,
              border: "1px solid",
              borderColor: "divider",
              borderRadius: "sm",
              bgcolor: "background.level1"
            }}
          >
            <Typography
              level="body-sm"
              sx={{
                color: "text.secondary"
              }}
            >
              이메일을 입력하세요
            </Typography>
          </Box>
        </Stack>

        <Stack spacing={1}>
          <Typography level="body-sm" fontWeight="500">
            메시지
          </Typography>
          <Box
            sx={{
              p: 2,
              minHeight: 100,
              border: "1px solid",
              borderColor: "divider",
              borderRadius: "sm",
              bgcolor: "background.level1"
            }}
          >
            <Typography
              level="body-sm"
              sx={{
                color: "text.secondary"
              }}
            >
              메시지를 입력하세요
            </Typography>
          </Box>
        </Stack>
      </Stack>

      <Stack direction="row" spacing={2} justifyContent="flex-end">
        <Button variant="outlined">취소</Button>
        <Button>전송</Button>
      </Stack>
    </Stack>
  </Sheet>
```

## Nested Sheets

Sheets can be nested to create layered dashboard layouts with distinct visual sections.

```tsx
<Sheet
    variant="outlined"
    sx={{
      maxWidth: 600,
      borderRadius: "lg",
      p: 3
    }}
  >
    <Stack spacing={3}>
      <Typography level="title-lg">대시보드</Typography>

      <Stack direction="row" spacing={2}>
        <Sheet
          variant="soft"
          color="primary"
          sx={{
            flex: 1,
            p: 2,
            borderRadius: "md"
          }}
        >
          <Typography
            level="body-sm"
            sx={{
              color: "primary.700"
            }}
          >
            활성 사용자
          </Typography>
          <Typography
            level="h3"
            sx={{
              color: "primary.800"
            }}
          >
            2,345
          </Typography>
        </Sheet>

        <Sheet
          variant="soft"
          color="success"
          sx={{
            flex: 1,
            p: 2,
            borderRadius: "md"
          }}
        >
          <Typography
            level="body-sm"
            sx={{
              color: "success.700"
            }}
          >
            완료된 작업
          </Typography>
          <Typography
            level="h3"
            sx={{
              color: "success.800"
            }}
          >
            156
          </Typography>
        </Sheet>
      </Stack>

      <Sheet
        variant="soft"
        sx={{
          p: 3,
          borderRadius: "md"
        }}
      >
        <Stack spacing={2}>
          <Typography level="title-md">최근 활동</Typography>

          <Stack spacing={1}>
            {[
              "새로운 사용자가 가입했습니다",
              "프로젝트가 완료되었습니다",
              "댓글이 등록되었습니다"
            ].map((activity) => (
              <Box
                key={activity}
                sx={{
                  p: 1.5,
                  bgcolor: "background.body",
                  borderRadius: "sm"
                }}
              >
                <Typography level="body-sm">{activity}</Typography>
              </Box>
            ))}
          </Stack>
        </Stack>
      </Sheet>
    </Stack>
  </Sheet>
```

## Common Use Cases

### Dashboard Stat Widget

```tsx
import { Sheet, Typography, Stack } from '@ceed/cds';

function StatWidget({ label, value, change }) {
  return (
    <Sheet variant="outlined" sx={{ p: 3, borderRadius: 'lg', minWidth: 200 }}>
      <Stack spacing={1}>
        <Typography level="body-sm" sx={{ color: 'text.secondary' }}>
          {label}
        </Typography>
        <Typography level="h2" color="primary">
          {value}
        </Typography>
        <Typography level="body-xs" sx={{ color: change > 0 ? 'success.600' : 'danger.600' }}>
          {change > 0 ? '+' : ''}
          {change}% from last month
        </Typography>
      </Stack>
    </Sheet>
  );
}
```

### Alert Banner

```tsx
import { Sheet, Typography, Stack, Button } from '@ceed/cds';
import WarningIcon from '@mui/icons-material/Warning';

function AlertBanner({ message, onDismiss }) {
  return (
    <Sheet variant="soft" color="warning" sx={{ borderRadius: 'md', p: 2 }}>
      <Stack direction="row" alignItems="center" spacing={2}>
        <WarningIcon />
        <Typography level="body-md" sx={{ flex: 1 }}>
          {message}
        </Typography>
        <Button size="sm" variant="plain" onClick={onDismiss}>
          Dismiss
        </Button>
      </Stack>
    </Sheet>
  );
}
```

### Content Card with Hover Effect

```tsx
import { Sheet, Typography, Stack } from '@ceed/cds';

function ClickableCard({ title, description, onClick }) {
  return (
    <Sheet
      variant="outlined"
      sx={{
        p: 3,
        borderRadius: 'lg',
        cursor: 'pointer',
        transition: 'all 0.2s',
        '&:hover': {
          boxShadow: 'md',
          transform: 'translateY(-2px)',
        },
      }}
      onClick={onClick}
    >
      <Stack spacing={1}>
        <Typography level="title-lg">{title}</Typography>
        <Typography level="body-md">{description}</Typography>
      </Stack>
    </Sheet>
  );
}
```

## Props and Customization

### Key Props

| Prop             | Type                                                           | Default     | Description                   |
| ---------------- | -------------------------------------------------------------- | ----------- | ----------------------------- |
| `children`       | `ReactNode`                                                    | -           | Sheet content                 |
| `variant`        | `'solid' \| 'soft' \| 'outlined' \| 'plain'`                   | `'plain'`   | Visual style                  |
| `color`          | `'primary' \| 'neutral' \| 'danger' \| 'success' \| 'warning'` | `'neutral'` | Color scheme                  |
| `invertedColors` | `boolean`                                                      | `false`     | Invert child component colors |
| `component`      | `ElementType`                                                  | `'div'`     | Root element type             |
| `sx`             | `SxProps`                                                      | -           | Custom styles                 |

> **Note**: Sheet also accepts all Joy UI Sheet props.

## Best Practices

- **Choose the right variant for the context.**
  - `outlined` for general-purpose cards and panels
  - `soft` for subtle emphasis or notification banners
  - `solid` for high-emphasis content that demands attention
  - `plain` for minimal or nested containers

- **Use semantic colors intentionally.**
  - `danger` for error states and destructive actions
  - `success` for confirmation messages and positive outcomes
  - `warning` for caution alerts and important notices
  - `primary` for highlighted or brand-related content
  - `neutral` for general, non-semantic content

- **Maintain consistent spacing.**
  - Use the `sx` prop with design tokens (`p: 3`, `borderRadius: 'lg'`) rather than arbitrary pixel values to keep layouts consistent across the application.

- **Avoid deeply nested Sheets.**
  - While nesting is supported, more than two levels of nesting can make the visual hierarchy confusing. Consider flattening the structure or using Divider components instead.

- **Prefer composition over complexity.**
  - Sheet is intentionally a low-level primitive. Compose it with Typography, Stack, Button, and other components rather than overloading the Sheet with custom styling.

## Accessibility

- Sheet renders as a `<div>` by default. When the content has a semantic meaning (e.g., a section or article), use the `component` prop to render an appropriate HTML element such as `<section>` or `<article>`.
- When a Sheet is interactive (clickable), ensure it has a proper `role` attribute (e.g., `role="button"`) and supports keyboard interaction via `tabIndex` and `onKeyDown`.
- Maintain sufficient color contrast between the Sheet background and its text content, especially when using `variant="solid"` with colored backgrounds.
- Avoid relying solely on color to convey information. Pair color indicators with icons or text labels for users with color vision deficiencies.
