C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

  • Installation
  • Button
  • Input
  • Badge
  • Card
  • Alert
  • Label
  • Table
  • Modal

Modal

A modal using the native HTML <dialog> element for maximum performance and accessibility.

Installation

bash
npx canx-ui add modal

Usage

You can trigger the modal using the built-in triggerLabel or by controlling the dialog element directly via ID.

tsx
import { Modal } from "@/components/ui/modal";
import { Button } from "@/components/ui/button";

export default function Demo() {
  return (
    <div className="flex gap-4">
      {/* Method 1: Built-in Trigger */}
      <Modal 
        id="modal-1" 
        triggerLabel="Open Project Modal" 
        title="Edit Project"
      >
        <div className="space-y-4 py-4">
          <p className="text-zinc-600">Make changes to your project here.</p>
          <div className="flex justify-end gap-2">
            <Button variant="ghost" onClick={() => document.getElementById('modal-1').close()}>Cancel</Button>
            <Button>Save Changes</Button>
          </div>
        </div>
      </Modal>
    </div>
  );
}

Headless Usage

You can also control the modal programmatically using the native API.

tsx
// Open
document.getElementById('my-modal').showModal();

// Close
document.getElementById('my-modal').close();