Button

Style-agnostic button component using CSS custom properties.

template 1 required7 optional3 slots0 a11y rules

Preview

variant
size
python
button(variant='primary', size='md', text='Primary')

Usage

views.py
python
from djust import LiveView


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

    def mount(self, request, **kwargs):
        self.variant = 'primary'
my_template.html
django
{% load theme_components %}
{% theme_button variant=variant size='md' text='Primary' %}

Props

NameTypeRequiredDefault
textstrrequired
variantstrprimary
sizestrmd
css_prefixstr
attrsdict
slot_iconstr
slot_contentstr
slot_loadingstr

Slots

slot_icon slot_content slot_loading
Source & styles
FilePathNotes
templatedjust_theming/components/button.htmlCopy it to the same path in your project, or per theme under djust_theming/themes/<theme>/components/.
cssdjust_theming/components.cssDefines 9 of this component's classes at line 131, 155, 161, 167, 174, 183, 192, 201, 211. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_components/components.cssDefines 8 of this component's classes at line 430, 433, 435, 439, 445, 447, 449, 450. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
cssdjust_theming/scaffold.cssDefines 6 of this component's classes at line 279, 302, 307, 312, 324, 337. 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 36. Override those rules, or the custom properties they read, in a stylesheet loaded after it.
CSS variables
--accent --accent-foreground --destructive --destructive-foreground --foreground --link --link-hover --primary --primary-foreground --radius --ring --secondary --secondary-foreground
Template source — button.html
django
<button class="{{ css_prefix }}btn {{ css_prefix }}btn-{{ variant }} {{ css_prefix }}btn-{{ size }} {% if attrs.class %}{{ attrs.class }}{% endif %}"
        {% if attrs.id %}id="{{ attrs.id }}"{% endif %}
        {% if attrs.onclick %}onclick="{{ attrs.onclick }}"{% endif %}
        {% if attrs.type %}type="{{ attrs.type }}"{% endif %}>
    {% if slot_loading %}{{ slot_loading|safe }}{% else %}{% if slot_icon %}{{ slot_icon|safe }} {% endif %}{% if slot_content %}{{ slot_content|safe }}{% else %}{{ text }}{% endif %}{% endif %}
</button>