M Majid DS mds
GitHub

Flux components

Modal

A dialog or flyout panel, opened from a trigger.

A trigger and a modal share a name. The previews here are live — click them.

Delete this order?

This cannot be undone and the order is cancelled entirely.

<flux:modal.trigger name="confirm-delete">
    <flux:button variant="danger" icon="trash">Delete order</flux:button>
</flux:modal.trigger>

<flux:modal name="confirm-delete" class="md:w-96">
    <div class="space-y-6">
        <div>
            <flux:heading size="lg">Delete this order?</flux:heading>
            <flux:text class="mt-2">This cannot be undone and the order is cancelled entirely.</flux:text>
        </div>

        <div class="flex gap-2">
            <flux:spacer />

            <flux:modal.close>
                <flux:button variant="ghost">Cancel</flux:button>
            </flux:modal.close>

            <flux:button variant="danger">Delete order</flux:button>
        </div>
    </div>
</flux:modal>

Flyout

variant="flyout" slides in from the trailing edge in both directions — the right in LTR, the left in RTL — with no extra classes.

Cart

AirSound Pro

1

Total

1,890,000 Toman
<flux:modal.trigger name="cart">
    <flux:button icon="shopping-cart">Cart</flux:button>
</flux:modal.trigger>

<flux:modal name="cart" variant="flyout" class="md:w-96">
    <div class="space-y-6">
        <flux:heading size="lg">Cart</flux:heading>

        <div class="flex items-center justify-between gap-3">
            <flux:text>AirSound Pro</flux:text>
            <mds:quantity :value="1" :min="1" :max="3" size="sm" />
        </div>

        <flux:separator />

        <div class="flex items-center justify-between">
            <flux:text>Total</flux:text>
            <mds:price :amount="1890000" />
        </div>

        <flux:button variant="primary" class="w-full">Checkout</flux:button>
    </div>
</flux:modal>

Keyboard shortcut

A trigger can open on a shortcut instead of a click.

No results found.
<flux:modal.trigger name="quick-search" shortcut="cmd.k">
    <flux:input as="button" placeholder="Press ⌘K" icon="magnifying-glass" kbd="⌘K" />
</flux:modal.trigger>

<flux:modal name="quick-search" variant="bare" class="w-full max-w-md">
    <mds:command>
        <mds:command.input placeholder="Search everything..." closable autofocus />

        <mds:command.items empty="No results found.">
            <mds:command.heading>Account</mds:command.heading>
            <mds:command.item icon="shopping-bag" kbd="⌘O">My orders</mds:command.item>
            <mds:command.item icon="wallet" kbd="⌘W">Wallet</mds:command.item>
        </mds:command.items>
    </mds:command>
</flux:modal>

Not dismissible

Force a decision by disabling the backdrop click and the escape key.

Accept the terms

You need to accept the terms before checking out.

<flux:modal.trigger name="terms">
    <flux:button>Accept terms</flux:button>
</flux:modal.trigger>

<flux:modal name="terms" :dismissible="false" :escapable="false" class="md:w-96">
    <div class="space-y-6">
        <flux:heading size="lg">Accept the terms</flux:heading>
        <flux:text>You need to accept the terms before checking out.</flux:text>

        <flux:modal.close>
            <flux:button variant="primary" class="w-full">I accept</flux:button>
        </flux:modal.close>
    </div>
</flux:modal>

Reference

flux:modal

PropDescription
nameIdentifier shared with its trigger.
variantOptions: flyout, bare. Default: a centred dialog.
positionFor flyouts: which edge it slides from.
dismissibleIf false, clicking the backdrop does not close it.
escapableIf false, Escape does not close it.
closableShows or hides the built-in close button.
scrollWhich part scrolls when the content is tall.

flux:modal.trigger

PropDescription
nameThe modal to open.
shortcutKeyboard shortcut that opens it, e.g. cmd.k.

flux:modal.close

Wraps any element so that clicking it closes the modal.

Related