Skip to content

[TwigComponent] CVA - boolean variants not working #1614

Closed
@gremo

Description

@gremo

Sadly, the boolean support for variants doesn't work. It's supposed two work.

The problem is true passed as string to the Twig. Is there a way to solve this issue

{% props theme = "primary", size = null, text = null, disabled = false %}

<button
    class="{{ cva({
        base: "btn",
        variants: {
            theme: {
                primary: "btn-primary",
                secondary: "btn-secondary",
                ghost: "btn-ghost",
                link: "btn-link",
            },
            size: {
                xs: "btn-xs",
                sm: "btn-sm",
                md: "btn-md",
                lg: "btn-lg",
            },
            disabled: {
                true: "btn-disabled",
            },
        },
        compoundVariants: [],
    }).apply({ theme, size }, attributes.render("class")|default("")) }}"
    {{ attributes.without("class") }}
>
    {% if block("content") is defined %}
        {{ block("content") }}
    {% elseif text|length %}
        {{ text }}
    {% endif %}
</button>

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions