<article class="n7-card n7-background-gray-01 rounded-md shadow-md transition hover:shadow-lg
   md:grid-cols-[min-content_1fr]
   is-card-fullclickable transition hover:shadow-lg group">

    <div class="n7-card__image w-12 md:w-16 lg:w-24 h-12 md:h-16 lg:h-24
  ">
        <img class="object-scale-down w-full h-full" alt="" src="/images/feathers.jpg" />
    </div>

    <div class="grid gap-2.5 md:gap-4">
        <div class="n7-card__heading flex flex-col-reverse gap-2.5 md:gap-4">
            <h3 class="n7-card__title text-lg md:text-xl font-bold">
                <a class="hover:underline group-hover:underline" href="">
                    Componente card esempio

                </a>
            </h3>

            <div class="flex items-baseline justify-between">

                <div class="n7-card__categories">
                    <span class="n7-category n7-content-placeholder">
                        Categoria
                    </span>
                </div>

            </div>

        </div>

        <p class="n7-card__excerpt text-base md:text-lg n7-content-03">
            Testo aggiuntivo da configurazione
        </p>

    </div>
</article>
<article
  class="n7-card{% block classes %}{% if classes %} {{ classes }}{% endif %}{% endblock %}
  {% if hasSideThumb %} md:grid-cols-[min-content_1fr]{% endif %}
  {% block fullClickable %}{% if fullClick %} is-card-fullclickable transition hover:shadow-lg group{% endif %}{% endblock fullClickable %}"
>
  {% if thumb %}
  <div class="n7-card__image{% if thumbSize %} {{ thumbSize }}{% endif %}
  {% if thumbAspectRatio %} {{ thumbAspectRatio }}{% endif %}">
    <img
      class="{% if img.imgObjectFit %}{{ img.imgObjectFit }}{% else %}object-cover{% endif %} w-full h-full"
      alt="{{ img.alt }}"
      src="{{ img.path }}"
    />
  </div>
  {% endif %}
  {% if icon %}
    <div class="{% if iconSize %}{{ iconSize }}{% endif %} p-6{% if iconRadius %} {{ iconRadius }}{% else %} rounded{% endif %} {% if iconBg %} {{ iconBg }}{% else %}n7-background-gray-02{% endif %}">
     {% render '@icon', { id: icon }, true %}
    </div>
  {% endif %}
  <div class="grid{% if contentGap %} {{ contentGap }}{% else %} gap-4{% endif %}">
    <div class="n7-card__heading flex flex-col-reverse{% if headingGap %} {{ headingGap }}{% else %} gap-4{% endif %}">
      <h3 class="n7-card__title {{ headingClasses }}">
        <a class="hover:underline{% if fullClick %} group-hover:underline{% endif %}" href="">
          {{ heading | safe }}
          {% block fileDetails %}
            {% if fileDetails %}<span class="flex gap-0.5 items-center pt-1 md:pt-2 text-sm md:text-base font-medium n7-content-03">
              {% render '@icon', { id: 'outline--document-text', size: 'w-4 h-4 md:w-5 md:h-5' }, true %}<span class="sr-only">, </span>PDF - 120Kb
            </span>
            {% endif %}
          {% endblock fileDetails %}
          {% if ctaLink %}<span class="sr-only">: Read more</span>{% endif %}
        </a>
      </h3>
      {% if category or date %}
        <div class="flex items-baseline justify-between">
          {% if category %}
          <div class="n7-card__categories">
            {% render '@category--overline', { text: categoryText, classes: 'n7-content-placeholder'}, true %}
          </div>
          {% endif %}
          {% if date %}
          <div class="n7-card__date text-sm">
            <time datetime="2023-09-30">30.09.2023</time>
          </div>
          {% endif %}
        </div>
      {% endif %}
    </div>

    {% block content %}
      {% if 'is-empty' not in excerpt %}
        <p class="n7-card__excerpt {{ excerptClasses }}">
           {% if excerpt %}{{ excerpt | safe }}{% else %}Neque blandit pellentesque nunc sed amet. Nisl, semper sed aliquam amet proin purus augue et.{% endif %}
        </p>
      {% endif %}
    {% endblock %} 

    {% if ctaLink %}
     {% render '@link--has-icon', { hasIcon: 'true', icon: ctaIcon, label: 'Read more', allyHidden: 'true' } %} 
    {% endif %}

    {% if cta %}
        <div class="">
        {% if fullClick %} 
        {% render '@button', { span: true, classes:'cursor-pointer', label: 'Card Cta'} %} 
        {% else %} 
        {% render '@button', { href:'#', classes: 'cursor-pointer', label: 'Card Cta'} %} 
        {% endif %}
        </div>
    {% endif %}
    {% if tags %}
      <ul class="flex gap-2 flex-wrap mt-auto" aria-label="Categorie">
        {% for i in range(0,4) %}
        <li>{% render '@chip--sm' %}</li>
        {% endfor %}
      </ul>
    {% endif %}
  </div>
</article>
{
  "categoryText": "Categoria",
  "iconSize": "w-24 h-24",
  "headingClasses": "text-lg md:text-xl font-bold",
  "heading": "Componente card esempio",
  "text": "Testo",
  "excerpt": "Testo aggiuntivo da configurazione",
  "excerptClasses": "text-base md:text-lg n7-content-03",
  "ctaIcon": "mini--arrow-small-right",
  "thumb": true,
  "fullClick": true,
  "classes": "n7-background-gray-01 rounded-md shadow-md transition hover:shadow-lg",
  "contentGap": "gap-2.5 md:gap-4",
  "headingGap": "gap-2.5 md:gap-4",
  "category": true,
  "hasSideThumb": true,
  "thumbSize": "w-12 md:w-16 lg:w-24 h-12 md:h-16 lg:h-24",
  "img": {
    "path": "/images/feathers.jpg",
    "alt": "",
    "imgObjectFit": "object-scale-down"
  }
}
  • Content:
    /* From INCLUSIVE COMPONENT LIBRARY by Heydon Pickering 
    * https://inclusive-components.design/
    * card pattern:
    * https://inclusive-components.design/cards/
    * Create redundant click event on the whole card, using only
    * card heading link
    * A click handler on the card's container element 
    * simply triggers the click method on the link inside it
    * Add also a delay in click, in order to detect if the user is selecting the text and not clicking
    */
    
    const cards = document.querySelectorAll('.n7-card.is-card-fullclickable');
    Array.prototype.forEach.call(cards, card => {
        let down, up, link = card.querySelector('.n7-card__title a');
        card.style.cursor = 'pointer';
        card.onmousedown = () => down = +new Date();
        card.onmouseup = () => {
            up = +new Date();
            if ((up - down) < 200) {
                link.click();
            }
        }
    });
  • URL: /components/raw/card/card.js
  • Filesystem Path: components/03-molecules/card/card.js
  • Size: 853 Bytes

Card demo components example. Multiple variants and settings.

Variable settings:

  • classes: value - add eventual classes
  • categoryText: value - override category text if needed (default is “Categoria”)
  • heading: value - card title
  • headingClasses: value - add/change heading classes if needed
  • contentGap: value - change content gap class if needed, default gap-4
  • headingGap: value - change heading elements gap class if needed, default gap-4
  • excerpt: value - excerpt text - text set by default in config, to disable in istance or card variant, use “is-hidden” value for this variable
  • excerptClasses: value - add/change excerpt classes if needed
  • icon: iconId - set top icon id and manage top icon visualization
  • iconSize: value - set icon width and height classes if needed (defaults are w-24 h-24)
  • iconRadius: value - manage top icon border radius - default rounded
  • iconBg: value - manage top icon background color - default n7-background-gray-02
  • ctaIcon: iconId - icon id for cta

Add the component in the card with “true” value

  • category: true (shows category)
  • ctaLink: true (shows cta link)
  • cta: true (shows cta button)
  • tags: true (shows tags list)
  • date: true (shows date)
  • thumb: true (shows thumb)
  • hasSideThumb: true (manage card class for side thumb - card grid class)
  • fullClick: true (Add the script which manage fullcard clickable area )

Manage image thumb settings:

  • img:
    • path: /pathto/image.jpg
    • alt: value - ‘Eventual alternative text if image is not descriptive’
    • imgObjectFit: value - manage img object fit if needed (default is cover)
  • thumbSize: value - manage thumb size if needed (for side thumb especially)
  • thumbAspectRatio: value - set aspect ratio classes if needed (used by default in has-thumb variant)