> Markdown version of [Styling](https://vaadin.com/docs/latest/fr/components/card/styling). Section index: [llms.txt](https://vaadin.com/docs/latest/fr/components/llms.txt)

# Style de Card

## <a id="variantes-de-style"></a>Variantes de style

Le composant Card prend en charge les variantes de style suivantes :

| Variante        | Description                                                            | Pris en charge par |
| --------------- | ---------------------------------------------------------------------- | ------------------ |
| `elevated`      | Ajoute une apparence surélevée avec un effet d’ombre                   | Aura, Lumo         |
| `outlined`      | Ajoute un contour de bordure pleine à la card                          | Aura, Lumo         |
| `horizontal`    | Place le contenu de la card horizontalement à côté de l’élément média  | Aura, Lumo         |
| `stretch-media` | Étire l’élément média pour remplir la largeur ou la hauteur de la card | Aura, Lumo         |
| `cover-media`   | Permet à l’élément média de couvrir la zone de padding de la card      | Aura, Lumo         |

**Lit** — `card-variants.ts`

```html
<vaadin-card card-title="Default">
  <div>This is the default card style.</div>
</vaadin-card>

<vaadin-card card-title="Outlined" theme="outlined">
  <div>Adds a solid outline around the card.</div>
</vaadin-card>

<vaadin-card card-title="Elevated" theme="elevated">
  <div>This variant works better on a shaded background.</div>
</vaadin-card>
```

**Flow** — `CardVariants.java`

```java
Card cardDefault = new Card();

Card cardOutlined = new Card();
cardOutlined.addThemeVariants(CardVariant.OUTLINED);

Card cardElevated = new Card();
cardElevated.addThemeVariants(CardVariant.ELEVATED);
```

**React** — `card-variants.tsx`

```tsx
<Card cardTitle="Default">
  <div>This is the default card style.</div>
</Card>

<Card cardTitle="Outlined" theme="outlined">
  <div>Adds a solid outline around the card.</div>
</Card>

<Card cardTitle="Elevated" theme="elevated">
  <div>This variant works better on a shaded background.</div>
</Card>
```

### <a id="horizontal"></a>Horizontal

Place tout le contenu de la card sur le côté de l’élément média, s’il est fourni.

**Lit** — `card-horizontal.ts`

```html
<!-- tag::[] -->
<vaadin-card theme="horizontal">
  <!-- end::[] -->
  <vaadin-avatar slot="media" name="Lapland"></vaadin-avatar>
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>
</vaadin-card>
```

**Flow** — `CardHorizontal.java`

```java
Card card = new Card();
card.addThemeVariants(CardVariant.HORIZONTAL);

card.setMedia(new Avatar("Lapland"));
card.setTitle(new Div("Lapland"));
card.setSubtitle(new Div("The Exotic North"));
card.add(new Div(
        "Lapland is the northern-most region of Finland and an active outdoor destination."));
```

**React** — `card-horizontal.tsx`

```tsx
{/* tag::[] */}
<Card theme="horizontal">
  {/* end::[] */}
  <Avatar slot="media" name="Lapland" />
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>
</Card>
```

### <a id="stretch-media"></a>Stretch Media

Étire l’élément média aussi large – ou aussi haut, s’il est combiné avec la variante horizontal – que la card, si l’élément média est une image, une vidéo, ou une icône.

**Lit** — `card-stretch-media.ts`

```html
<!-- tag::[] -->
<vaadin-card theme="stretch-media">
  <!-- end::[] -->
  <img slot="media" width="100" src="${img}" alt="" />
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>
    Lapland is the northern-most region of Finland and an active outdoor destination.
  </div>
</vaadin-card>

<!-- tag::[] -->
<vaadin-card theme="stretch-media">
  <!-- end::[] -->
  <vaadin-icon
    slot="media"
    icon="lumo:photo"
    style="background: rgba(0, 0, 0, 0.2)"
  ></vaadin-icon>
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>
    Lapland is the northern-most region of Finland and an active outdoor destination.
  </div>
</vaadin-card>
```

**Flow** — `CardStretchMedia.java`

```java
// Card with stretched image
Card imageCard = new Card();
imageCard.addThemeVariants(CardVariant.STRETCH_MEDIA);

DownloadHandler imageHandler = DownloadHandler.forClassResource(
        getClass(), "/images/lapland.avif", "lapland.avif");
Image image = new Image(imageHandler, "");
imageCard.setMedia(image);

imageCard.setTitle(new Div("Lapland"));
imageCard.setSubtitle(new Div("The Exotic North"));
imageCard.add(new Div(
        "Lapland is the northern-most region of Finland and an active outdoor destination."));

// Card with stretched icon
Card iconCard = new Card();
iconCard.addThemeVariants(CardVariant.STRETCH_MEDIA);

Icon icon = LumoIcon.PHOTO.create();
icon.getStyle().setBackgroundColor("rgba(0, 0, 0, 0.2)");
iconCard.setMedia(icon);

iconCard.setTitle(new Div("Lapland"));
iconCard.setSubtitle(new Div("The Exotic North"));
iconCard.add(new Div(
        "Lapland is the northern-most region of Finland and an active outdoor destination."));
```

**React** — `card-stretch-media.tsx`

```tsx
{/* tag::[] */}
<Card theme="stretch-media">
  {/* end::[] */}
  <img slot="media" width="200" src={img} alt="" />
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>
</Card>

{/* tag::[] */}
<Card theme="stretch-media">
  {/* end::[] */}
  <Icon slot="media" icon="lumo:photo" style={{ background: 'rgba(0, 0, 0, 0.2)' }} />
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>
</Card>
```

### <a id="cover-media"></a>Cover Media

Semblable à la variante stretch-media, mais cette variante permet à l’élément média de couvrir également la zone de padding de la card. Cette variante remplace la variante stretch-media.

**Lit** — `card-cover-media.ts`

```html
<!-- tag::[] -->
<vaadin-card theme="cover-media">
  <!-- end::[] -->
  <img slot="media" width="100" src="${img}" alt="" />
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>
    Lapland is the northern-most region of Finland and an active outdoor destination.
  </div>
</vaadin-card>

<!-- tag::[] -->
<vaadin-card theme="cover-media">
  <!-- end::[] -->
  <vaadin-icon
    slot="media"
    icon="lumo:photo"
    style="background: rgba(0, 0, 0, 0.2)"
  ></vaadin-icon>
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>
    Lapland is the northern-most region of Finland and an active outdoor destination.
  </div>
</vaadin-card>
```

**Flow** — `CardCoverMedia.java`

```java
// Card with cover image
Card imageCard = new Card();
imageCard.addThemeVariants(CardVariant.COVER_MEDIA);

DownloadHandler imageHandler = DownloadHandler.forClassResource(
        getClass(), "/images/lapland.avif", "lapland.avif");
Image image = new Image(imageHandler, "");
imageCard.setMedia(image);

imageCard.setTitle(new Div("Lapland"));
imageCard.setSubtitle(new Div("The Exotic North"));
imageCard.add(new Div(
        "Lapland is the northern-most region of Finland and an active outdoor destination."));

// Card with cover icon
Card iconCard = new Card();
iconCard.addThemeVariants(CardVariant.COVER_MEDIA);

Icon icon = LumoIcon.PHOTO.create();
icon.getStyle().setBackgroundColor("rgba(0, 0, 0, 0.2)");
iconCard.setMedia(icon);

iconCard.setTitle(new Div("Lapland"));
iconCard.setSubtitle(new Div("The Exotic North"));
iconCard.add(new Div(
        "Lapland is the northern-most region of Finland and an active outdoor destination."));
```

**React** — `card-cover-media.tsx`

```tsx
{/* tag::[] */}
<Card theme="cover-media">
  {/* end::[] */}
  <img slot="media" width="200" src={img} alt="" />
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>
</Card>

{/* tag::[] */}
<Card theme="cover-media">
  {/* end::[] */}
  <Icon slot="media" icon="lumo:photo" style={{ background: 'rgba(0, 0, 0, 0.2)' }} />
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>
</Card>
```

### <a id="combiner-les-variantes"></a>Combiner les variantes

Vous pouvez combiner toutes les variantes de style ensemble.

**Lit** — `card-combine-variants.ts`

```html
<!-- tag::[] -->
<vaadin-card theme="outlined elevated horizontal cover-media">
  <!-- end::[] -->
  <img slot="media" width="100" src="${img}" alt="" />
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>
</vaadin-card>
```

**Flow** — `CardCombineVariants.java`

```java
Card card = new Card();
card.addThemeVariants(
        CardVariant.OUTLINED,
        CardVariant.ELEVATED,
        CardVariant.HORIZONTAL,
        CardVariant.COVER_MEDIA
);

DownloadHandler imageHandler = DownloadHandler.forClassResource(
        getClass(), "/images/lapland.avif", "lapland.avif");
Image image = new Image(imageHandler, "");
image.setWidth("200px");
card.setMedia(image);

card.setTitle(new Div("Lapland"));
card.setSubtitle(new Div("The Exotic North"));
card.add(new Div(
        "Lapland is the northern-most region of Finland and an active outdoor destination."));
```

**React** — `card-combine-variants.tsx`

```tsx
{/* tag::[] */}
<Card theme="outlined elevated horizontal cover-media">
  {/* end::[] */}
  <img slot="media" width="200" src={img} alt="" />
  <div slot="title">Lapland</div>
  <div slot="subtitle">The Exotic North</div>
  <div>Lapland is the northern-most region of Finland and an active outdoor destination.</div>
</Card>
```

## <a id="propriétés-de-style"></a>Propriétés de style

Les propriétés de style suivantes peuvent être utilisées dans des feuilles de style CSS pour personnaliser l’apparence de ce composant.

Pour appliquer des valeurs à ces propriétés globalement dans l’UI de votre application, placez-les dans un bloc CSS en utilisant le sélecteur `html {…​}`. Voir [Component Style Properties](https://vaadin.com/docs/latest/fr/styling/styling-components.md#component-style-properties) pour plus d’informations sur les propriétés de style.

### <a id="propriétés-courantes"></a>Propriétés courantes

| Propriété                            | Pris en charge par |
| ------------------------------------ | ------------------ |
| `--vaadin-card-background`           | Aura, Lumo         |
| `--vaadin-card-shadow`               | Aura, Lumo         |
| `--vaadin-card-border-width`         | Aura, Lumo         |
| `--vaadin-card-border-color`         | Aura, Lumo         |
| `--vaadin-card-border-radius`        | Aura, Lumo         |
| `--vaadin-card-padding`              | Aura, Lumo         |
| `--vaadin-card-gap`                  | Aura, Lumo         |
| `--vaadin-card-media-aspect-ratio`   | Aura, Lumo         |
| `--vaadin-card-title-color`          | Aura, Lumo         |
| `--vaadin-card-title-font-size`      | Aura, Lumo         |
| `--vaadin-card-title-font-weight`    | Aura, Lumo         |
| `--vaadin-card-title-line-height`    | Aura, Lumo         |
| `--vaadin-card-subtitle-color`       | Aura, Lumo         |
| `--vaadin-card-subtitle-font-size`   | Aura, Lumo         |
| `--vaadin-card-subtitle-line-height` | Aura, Lumo         |

## <a id="sélecteurs-css"></a>Sélecteurs CSS

Les sélecteurs CSS suivants peuvent être utilisés dans des feuilles de style pour cibler les différentes parties et états du composant. Voir la [documentation Styling](https://vaadin.com/docs/latest/fr/styling.md) pour plus de détails sur la manière de styliser les composants.

> **Important: Pas pour Shadow DOM**
>
> Ces sélecteurs doivent être utilisés dans `styles.css` ou dans une autre feuille de style chargée avec l’annotation `@StyleSheet` ou la règle CSS `@import`. **Ils ne fonctionnent pas dans le shadow DOM des composants Vaadin**, comme dans les feuilles de style du sous-dossier `components` ou chargées avec la propriété `themeFor` de l’annotation `@CssImport`.

---

- Élément racine

  `vaadin-card`

### <a id="parties"></a>Parties

- Média

  `vaadin-card::part(media)`

- En-tête

  `vaadin-card::part(header)`

- Contenu

  `vaadin-card::part(content)`

- Pied de page

  `vaadin-card::part(footer)`

- Titre

  `vaadin-card [slot="title"]`

### <a id="variantes-de-style-2"></a>Variantes de style

- Outlined

  `vaadin-card[theme~="outlined"]`

- Elevated

  `vaadin-card[theme~="elevated"]`

- Horizontal

  `vaadin-card[theme~="horizontal"]`

- Stretch Media

  `vaadin-card[theme~="stretch-media"]`

- Cover Media

  `vaadin-card[theme~="cover-media"]`
