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.
English | 简体中文
Features
- 🎨 29 Components - Buttons, Inputs, Cards, Menus, Dialogs 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-qml
Quick Start
Basic Usage
import sys
from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine
from PySide6.QtQuickControls2 import QQuickStyle
from chakra 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
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 propsCFlex- Flexbox layout containerCCenter- Center alignment containerCContainer- Responsive container with max-width
Forms
CButton- Versatile button with variants and sizesCInput- Text input with validation statesCCheckbox- Checkbox with indeterminate stateCSwitch- Toggle switch with labelsCSelect- Dropdown select with search
Data Display
CCard- Content card with header/footerCBadge- Small status indicatorCTag- Removable tag componentCProgress- Progress bar with variantsCSpinner- Loading spinner
Feedback
CAlert- Alert messages with statusCTooltip- Hover tooltip
Overlay
CDialog- Modal dialogCDrawer- Side drawer/panelCMenu- Dropdown menuCMenuItem- Menu item component
Navigation
CPagination- Pagination controlsCSegmentedControl- Segmented picker
Other
CWindow- Frameless window with native shadowCIcon- Icon component with 100+ iconsCScrollBar- Custom scrollbarCScrollArea- Scrollable areaCActionBar- 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
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.effectusage - ✅ 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
Development
Building from Source
# Install dependencies
uv sync --group dev
# Build QML module (auto-generate qmldir)
uv run build-chakra
# Package for distribution
uv build
# Install locally for testing
uv add dist/chakra_qml-*.whl
The build-chakra command automatically:
- Scans all
.qmlfiles insrc/Chakra/ - Detects singleton components (files with
pragma Singleton) - Generates
qmldirmodule definition
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Credits
Inspired by Chakra UI by Segun Adebayo.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chakra_qml-0.0.7.tar.gz.
File metadata
- Download URL: chakra_qml-0.0.7.tar.gz
- Upload date:
- Size: 251.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
464d0613d9add87a7efb3d5ce3d27f6443e881950ab80eb6d09582bcb10f7bd3
|
|
| MD5 |
45b47736f2229bfe72f97211cd8e9b28
|
|
| BLAKE2b-256 |
4ff2e0adb9f1a1b7c625bd8603a0eca01535d5e37dfa815b7c1e1406e0a9cfdc
|
File details
Details for the file chakra_qml-0.0.7-py3-none-any.whl.
File metadata
- Download URL: chakra_qml-0.0.7-py3-none-any.whl
- Upload date:
- Size: 270.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7fdf47fbce399a74b62ae019c7993e90e627610554eaf02c4d10dff624d9229
|
|
| MD5 |
264aa913ab469f37cc25be2513c3f890
|
|
| BLAKE2b-256 |
18497f4f1c2a434b3f4027843f3d16d372173d09b36a2fe711ea48e52bd772ca
|