{#- chirp-ui: Card component Headless card with optional header, footer, collapsible, and variants. Named slots: header_actions, media, body_actions (for list cards), default (body). Link variants also expose header_badge, header_subtitle, top_meta, and footer. Usage: from "chirpui/card.html" import card call card(title="My Card")

Card body content.

end call card(title="Settings", icon="⚙") {% slot header_actions %}{% end %}

Body content.

end call card(title="Feature", variant="feature") {% slot media %}...{% end %}

Body content.

end call card(title="Usage", attrs_map={"id": "usage-widget"})

Stable id on the outer article for hx-target="#usage-widget".

end -#} {% def card(title=none, subtitle=none, footer=none, collapsible=false, open=false, variant="", icon=none, border_variant="", header_variant="", cls="", hoverable=false, attrs="", attrs_map=none) %} {% set variant_class = " chirpui-card--" ~ variant if variant else "" %} {% set border_class = " chirpui-card--gradient-border" if border_variant == "gradient" else "" %} {% set header_class = " chirpui-card--gradient-header" if header_variant == "gradient" else "" %} {% set hover_class = " chirpui-card--hoverable" if hoverable else "" %} {% if collapsible %}
{% if title %} {% if icon %}{{ icon | icon }}{% end %}
{{ title }} {% if subtitle %}

{{ subtitle }}

{% end %}
{% slot header_actions %}
{% end %}
{% slot media %}
{% slot %}
{% slot body_actions %}
{% if footer %} {% end %}
{% else %}
{% if title %}
{% if icon %}{{ icon | icon }}{% end %}
{{ title }} {% if subtitle %}

{{ subtitle }}

{% end %}
{% slot header_actions %}
{% end %}
{% slot media %}
{% slot %}
{% slot body_actions %}
{% if footer %} {% end %}
{% end %} {% end %} {% def card_header(title, subtitle=none, icon=none, cls="") %}
{% if icon %}{{ icon | icon }}{% end %}
{{ title }} {% if subtitle %}

{{ subtitle }}

{% end %}
{% slot %}
{% end %} {% def card_media(cls="") %}
{% slot %}
{% end %} {# Link-styled card for navigation/index grids. Named slots: header_badge (top-left chip/badge), header_subtitle (beneath title, e.g. aliases), footer (below hr, e.g. tags), default (body). #} {% def card_link(href, title, cls="") %}
{% slot header_badge %}
{{ title }}
{% slot header_subtitle %}
{% slot %}
{% end %} {# Partially linked card for list grids with independent source/footer links. Named slots: top_meta (above main link), header_badge, header_subtitle, footer, default (body). #} {% def card_main_link(href, title, cls="") %}
{% slot top_meta %}
{% slot header_badge %}
{{ title }}
{% slot header_subtitle %}
{% slot %}
{% end %} {# Opinionated list/index card for app resources. Named slots: badges, subtitle, footer, default (body extras). link_mode="all" uses a whole-card link; link_mode="main" keeps top/footer content independently interactive. #} {% def resource_card(href, title, description=none, top_meta=none, top_meta_href=none, top_meta_title=none, cls="", link_mode="all") %} {% set link_mode = link_mode | validate_variant(("all", "main"), "all") %} {% if link_mode == "main" %}
{% if top_meta %}
{% if top_meta_href %} {{ top_meta }} {% else %} {{ top_meta }} {% endif %}
{% endif %}
{% slot badges %}
{{ title }}
{% slot subtitle %}
{% if description %}

{{ description }}

{% endif %} {% slot %}
{% else %} {% if top_meta %}
{{ top_meta }}
{% endif %}
{% slot badges %}
{{ title }}
{% slot subtitle %}
{% if description %}

{{ description }}

{% endif %} {% slot %}
{% endif %} {% end %}