Skip to main content

A modern QML component library inspired by Chakra UI

Project description

Chakra UI QML

A modern, accessible, and customizable QML component library inspired by Chakra UI.

Features

  • 🎨 33+ Components - Buttons, Inputs, Cards, Menus, Dialogs, Sidebar and more
  • 🌓 Dark Mode - Built-in theme system with light/dark modes
  • High Performance - Optimized rendering with minimal overhead
  • 🪟 Frameless Window - Native Windows DWM shadow and custom title bar
  • 🎯 Type Safe - Full PySide6 integration with type hints
  • 📱 Responsive - Adaptive layouts and sizing system
  • Accessible - ARIA-compliant components (where applicable)

Installation

pip install chakra-qtquick

Quick Start

Basic Usage

import sys
from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtQuickControls2 import QQuickStyle
from chakra_ui import init

QQuickStyle.setStyle("Basic")
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
init(engine)  # 注册 Chakra 组件
engine.load("main.qml")
sys.exit(app.exec())

QML Example

import QtQuick
import Chakra 1.0

CWindow {
    width: 800
    height: 600
    title: "My App"
    
    Column {
        spacing: 16
        anchors.centerIn: parent
        
        CButton {
            text: "Click Me"
            colorScheme: "blue"
            onClicked: console.log("Clicked!")
        }
        
        CInput {
            placeholderText: "Enter text..."
            variant: "outline"
        }
        
        CCard {
            title: "Welcome"
            description: "This is a Chakra UI component"
            width: 300
        }
    }
}

Available Components

Layout

  • CBox - Flexible container with styling props
  • CFlex - Flexbox layout container
  • CCenter - Center alignment container
  • CContainer - Responsive container with max-width

Forms

  • CButton - Versatile button with variants and sizes
  • CInput - Text input with validation states
  • CCheckbox - Checkbox with indeterminate state
  • CSwitch - Toggle switch with labels
  • CSelect - Dropdown select with search

Data Display

  • CCard - Content card with header/footer
  • CBadge - Small status indicator
  • CTag - Removable tag component
  • CProgress - Progress bar with variants
  • CSpinner - Loading spinner

Feedback

  • CAlert - Alert messages with status
  • CTooltip - Hover tooltip

Overlay

  • CDialog - Modal dialog
  • CDrawer - Side drawer/panel
  • CMenu - Dropdown menu
  • CMenuItem - Menu item component

Navigation

  • CPagination - Pagination controls
  • CSegmentedControl - Segmented picker
  • CSidebar - Collapsible sidebar navigation
  • CSidebarItem - Sidebar navigation item
  • CSidebarGroup - Sidebar item group
  • CSidebarSeparator - Sidebar separator

Other

  • CWindow - Frameless window with native shadow
  • CIcon - Icon component with 100+ icons
  • CScrollBar - Custom scrollbar
  • CScrollArea - Scrollable area
  • CActionBar - Floating action bar

Theme Customization

The library uses a centralized AppStyle singleton for theming:

// Toggle theme
AppStyle.toggleTheme()

// Check current theme
if (AppStyle.isDark) {
    // Dark mode
}

// Access theme colors
color: AppStyle.primaryColor
color: AppStyle.textColor
color: AppStyle.backgroundColor

Component Props

CButton

CButton {
    text: "Button"
    variant: "solid"        // solid, outline, ghost, link
    colorScheme: "blue"     // blue, green, red, purple, etc.
    size: "md"              // sm, md, lg
    leftIcon: "check"
    rightIcon: "arrow-right"
    isLoading: false
    fullWidth: false
}

CInput

CInput {
    placeholderText: "Enter text"
    variant: "outline"      // outline, filled, flushed
    size: "md"              // sm, md, lg
    isInvalid: false
    isDisabled: false
    isClearable: true
    type: "text"            // text, password
}

CCard

CCard {
    title: "Card Title"
    description: "Card description"
    variant: "elevated"     // elevated, outline, filled, subtle
    size: "md"              // sm, md, lg
    
    // Custom content
    CButton { text: "Action" }
}

Frameless Window

Create modern frameless windows with native Windows shadow:

import Chakra 1.0

CWindow {
    width: 1280
    height: 800
    title: "My App"
    
    showTitleBar: true
    showThemeToggle: true
    showMinimize: true
    showMaximize: true
    showClose: true
    shadowEnabled: true     // Native DWM shadow on Windows
    
    // Your content here
}

Performance

This library is optimized for performance:

  • ✅ No unnecessary layer.effect usage
  • ✅ Efficient property bindings
  • ✅ Cached color mappings in AppStyle
  • ✅ Native Windows API for frameless window
  • ✅ Minimal animation overhead

Examples

Check the demo folder for complete examples:

  • Basic components showcase
  • Form validation
  • Data tables
  • Dashboard layouts
  • Settings pages

Requirements

  • Python >= 3.8
  • PySide6 >= 6.5.0

Testing

This library includes a comprehensive test suite for both QML components and Python modules.

Running Tests

# Run QML component tests
python tests/run_qml_tests.py

# Run Python unit tests
python tests/run_python_tests.py

See tests/README.md for detailed testing documentation.

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Credits

Inspired by Chakra UI by Segun Adebayo.

Author

ASLant

Documentation

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chakra_qml-0.0.2.tar.gz (250.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chakra_qml-0.0.2-py3-none-any.whl (268.3 kB view details)

Uploaded Python 3

File details

Details for the file chakra_qml-0.0.2.tar.gz.

File metadata

  • Download URL: chakra_qml-0.0.2.tar.gz
  • Upload date:
  • Size: 250.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for chakra_qml-0.0.2.tar.gz
Algorithm Hash digest
SHA256 20cd8ba1a4e00af0c97f97ed64d452664eea127995f03709742b671fb253f88c
MD5 9d43a7dd3150f6297a8c53d5f12c675f
BLAKE2b-256 edbb19d0526050b2bed46adb2378b53b46dc6267915034b22c31af03901a960e

See more details on using hashes here.

File details

Details for the file chakra_qml-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: chakra_qml-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 268.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for chakra_qml-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 16c3458c2d86de6272fac5c3e573e9968ba29fa3ab54cd14644793049548ef4a
MD5 bffbe8d4e2a5fa4b79cf4910f0d1455b
BLAKE2b-256 619fcc5423b994aeb5e2030b6e7edc78e850e0f54242afa9337d1e9a4f28eb26

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page