Card

Style-agnostic card container using CSS custom properties.

template 0 required8 optional3 slots0 a11y rules

Preview

Card Title

Card body content goes here.

No Footer

A card without a footer.
A card with no title or footer.

Usage

views.py
python
from djust import LiveView


class MyView(LiveView):
    template_name = "my_template.html"

    def mount(self, request, **kwargs):
        self.title = 'Card Title'
my_template.html
django
{% load theme_components %}
{% theme_card title=title footer='Card footer' %}

Props

NameTypeRequiredDefault
titleOptional[str]
contentstr
footerOptional[str]
css_prefixstr
attrsdict
slot_headerstr
slot_bodystr
slot_footerstr

Slots

slot_header slot_body slot_footer
Source & styles
FilePathNotes
templatedjust_theming/components/card.htmlCopy it to the same path in your project, or per theme under djust_theming/themes/<theme>/components/.
cssdjust_theming/components.cssDefines 5 of this component's classes at line 226, 232, 243, 250, 254. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_components/components.cssDefines 5 of this component's classes at line 160, 165, 166, 168, 169. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_theming/scaffold.cssDefines 4 of this component's classes at line 380, 388, 405, 409. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_theming/catalogue.cssDefines 1 of this component's classes at line 122. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_theming/performance.cssDefines 1 of this component's classes at line 37. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_theming/print.cssDefines 1 of this component's classes at line 66. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
CSS variables
--border --card --card-foreground --foreground --radius --shadow-sm --space-4 --space-5
Template source — card.html
django
<div class="{{ css_prefix }}card {% if attrs.class %}{{ attrs.class }}{% endif %}"
     {% if attrs.id %}id="{{ attrs.id }}"{% endif %}>
    {% if slot_header %}
    <div class="{{ css_prefix }}card-header">
        {{ slot_header|safe }}
    </div>
    {% elif title %}
    <div class="{{ css_prefix }}card-header">
        <h3 class="{{ css_prefix }}card-title">{{ title }}</h3>
    </div>
    {% endif %}
    <div class="{{ css_prefix }}card-body">
        {% if slot_body %}{{ slot_body|safe }}{% endif %}
    </div>
    {% if slot_footer %}
    <div class="{{ css_prefix }}card-footer">
        {{ slot_footer|safe }}
    </div>
    {% elif footer %}
    <div class="{{ css_prefix }}card-footer">
        {{ footer }}
    </div>
    {% endif %}
</div>