# Card

The Card component is a versatile container used to group related information in a visually distinct way. It often includes elements like a header, body, and footer, providing a cohesive layout for displaying content such as text, images, and actions. Cards enhance the user experience by organizing information into manageable sections.

## Overview

```tsx
import { Card } from 'welcome-ui/Card'
import { Icon } from 'welcome-ui/Icon'

const Example = () => {
  return (
    <>
      <p className="mb-16">
        A card doesn't have padding by default. To add padding to a card, you should wrap your
        content in a <strong>Card.Body</strong> which has default padding.
      </p>

      <Card className="max-w-2/3">
        <Card.Body>
          <h3 className="flex items-center gap-4">
            <Icon name="book-alt" size="lg" />
            The Jungle Book
          </h3>
          <p>
            After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
            Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
            free-spirited bear Baloo.
          </p>
        </Card.Body>
      </Card>
    </>
  )
}

export default Example
```

## Examples

### Header

The `Card.Header` should be placed at the top of the `Card.Body` component to display titles or introductory content. The `onClose` prop can be provided to automatically add a close button on the top right corner. The close button can be disabled by setting the `disabled` prop to true.

```tsx
import { Card } from 'welcome-ui/Card'
import { Icon } from 'welcome-ui/Icon'

const Example = () => {
  return (
    <>
      <Card className="max-w-2/3">
        <Card.Header>
          <Icon name="book-alt" />
          The Jungle Book
        </Card.Header>
        <Card.Body>
          After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
          Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
          free-spirited bear Baloo.
        </Card.Body>
      </Card>

      <Card className="max-w-2/3">
        <Card.Header onClose={() => alert('Closing card')}>
          <Icon name="book-alt" />
          The Jungle Book
        </Card.Header>
        <Card.Body>
          After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
          Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
          free-spirited bear Baloo.
        </Card.Body>
      </Card>

      <Card className="max-w-2/3">
        <Card.Header disabled onClose={() => alert('Closing card')} />
        <Card.Body>
          <h3 className="flex items-center gap-4">
            <Icon name="book-alt" size="lg" />
            The Jungle Book (disabled close)
          </h3>
          After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
          Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
          free-spirited bear Baloo.
        </Card.Body>
      </Card>
    </>
  )
}

export default Example
```

### Footer

The `Card.Footer` should be placed at the bottom of the `Card.Body` component to display supplementary information or actions related to the card's content.

```tsx
import { Button } from 'welcome-ui/Button'
import { Card } from 'welcome-ui/Card'
import { Icon } from 'welcome-ui/Icon'

const Example = () => {
  return (
    <>
      <Card className="max-w-2/3">
        <Card.Body>
          After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
          Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
          free-spirited bear Baloo.
        </Card.Body>
        <Card.Footer>
          <Button variant="primary">Learn More</Button>
          <Button variant="secondary">Bookmark</Button>
          <Button className="ml-auto" variant="tertiary">
            <Icon name="share" />
          </Button>
        </Card.Footer>
      </Card>
    </>
  )
}

export default Example
```

### Sizes

You can control the padding/font-size and overall size of the Card by using the `size` prop with the following options: `sm`, `md` (default) and `lg`.

```tsx
import { Button } from 'welcome-ui/Button'
import { Card } from 'welcome-ui/Card'
import { Icon } from 'welcome-ui/Icon'

const Example = () => {
  return (
    <>
      <Card className="max-w-2/3" size="sm">
        <Card.Header onClose={() => {}}>
          <Icon name="book-alt" />
          The Jungle Book (sm)
        </Card.Header>
        <Card.Body metadata="1894 ‧ Adventure/Drama">
          After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
          Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
          free-spirited bear Baloo.
        </Card.Body>
        <Card.Footer>
          <Button size="md" variant="primary">
            Learn More
          </Button>
          <Button size="md" variant="secondary">
            Bookmark
          </Button>
          <Button className="ml-auto" variant="tertiary">
            <Icon name="share" />
          </Button>
        </Card.Footer>
      </Card>

      <Card className="max-w-2/3" size="md">
        <Card.Header onClose={() => {}}>
          <Icon name="book-alt" />
          The Jungle Book (md)
        </Card.Header>
        <Card.Body metadata="1894 ‧ Adventure/Drama">
          After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
          Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
          free-spirited bear Baloo.
        </Card.Body>
        <Card.Footer>
          <Button variant="primary">Learn More</Button>
          <Button variant="secondary">Bookmark</Button>
          <Button className="ml-auto" variant="tertiary">
            <Icon name="share" />
          </Button>
        </Card.Footer>
      </Card>

      <Card className="max-w-2/3" size="lg">
        <Card.Header onClose={() => {}}>
          <Icon name="book-alt" />
          The Jungle Book (lg)
        </Card.Header>
        <Card.Body metadata="1894 ‧ Adventure/Drama">
          After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
          Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
          free-spirited bear Baloo.
        </Card.Body>
        <Card.Footer>
          <Button variant="primary">Learn More</Button>
          <Button variant="secondary">Bookmark</Button>
          <Button className="ml-auto" variant="tertiary">
            <Icon name="share" />
          </Button>
        </Card.Footer>
      </Card>
    </>
  )
}

export default Example
```

### Link card

You can use the `as` prop to render the Card as a different HTML element, such as an anchor (`<a>`) tag for link cards.

```tsx
import { Card } from 'welcome-ui/Card'
import { Icon } from 'welcome-ui/Icon'

const Example = () => {
  return (
    <>
      <Card
        as="a"
        className="max-w-2/3"
        href="https://www.welcometothejungle.com"
        rel="noopener nofollow"
        target="_blank"
      >
        <Card.Body>
          <h3 className="flex items-center gap-4">
            <Icon name="book-alt" size="lg" />
            The Jungle Book
          </h3>
          <p>
            After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
            Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
            free-spirited bear Baloo.
          </p>
        </Card.Body>
      </Card>
    </>
  )
}

export default Example
```

### Disabled card

```tsx
import { Card } from 'welcome-ui/Card'
import { Icon } from 'welcome-ui/Icon'

const Example = () => {
  return (
    <>
      <Card className="max-w-2/3" disabled>
        <Card.Header disabled onClose={() => {}}>
          <Icon name="book-alt" />
          The Jungle Book (disabled)
        </Card.Header>
        <Card.Body metadata="1894 ‧ Adventure/Drama">
          After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
          Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
          free-spirited bear Baloo.
        </Card.Body>
      </Card>
    </>
  )
}

export default Example
```

### Content card

```tsx
import { Card } from 'welcome-ui/Card'
import { Text } from 'welcome-ui/Text'

const Example = () => {
  const url =
    'https://m.media-amazon.com/images/M/MV5BMzE0NzgyODIxN15BMl5BanBnXkFtZTgwNDU0NjU5NzE@._V1_SX1777_CR0,0,1777,994_AL_.jpg'

  return (
    <Card className="max-w-2/3">
      <Card.Cover alt="The Jungle Book" className="w-full" src={url} />
      <Card.Body metadata="1894 ‧ Adventure/Drama">
        <Text as="h4" className="font-bold text-neutral-90">
          The Jungle Book
        </Text>
        After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named
        Mowgli embarks on a journey of self discovery with the help of panther Bagheera and
        free-spirited bear Baloo.
      </Card.Body>
    </Card>
  )
}

export default Example
```

### Picture card

```tsx
import { Card } from 'welcome-ui/Card'
import { Text } from 'welcome-ui/Text'

const Example = () => {
  const url =
    'https://m.media-amazon.com/images/M/MV5BMzE0NzgyODIxN15BMl5BanBnXkFtZTgwNDU0NjU5NzE@._V1_SX1777_CR0,0,1777,994_AL_.jpg'

  return (
    <Card
      className={`items-end bg-cover bg-center bg-no-repeat h-7xl max-w-2/3 flex w-full`}
      style={{ backgroundImage: `url(${url})` }}
    >
      <div className="bg-linear-to-t from-neutral-80 to-neutral-80/0 p-xl w-full">
        <Text as="h4" className="font-bold text-neutral-10 m-0">
          The Jungle Book
        </Text>
      </div>
    </Card>
  )
}

export default Example
```

## Props

### Card.Body

```tsx
interface CardBodyProps {
  metadata?: string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal
}
```

### Card.Cover

```tsx
interface CardCoverProps {
  alt: string
  src: string
}
```

### Card.Header

```tsx
interface CardHeaderProps {
  disabled?: boolean
  onClose?: () => void
}
```

### Card

```tsx
interface CardProps {
  disabled?: boolean
  size?: 'lg' | 'md' | 'sm'
}
```