lib-slint-expert
Slint GUI Expert
A comprehensive guide for developing modern GUI applications using Slint with Rust. This skill is built directly from the official Slint repository and covers everything from basic component creation to advanced performance optimization and cross-platform deployment.
🎯 Getting Started with Official Tutorial
The best way to start is by following the official tutorial:
- Start Here:
@source/docs/astro/src/content/docs/tutorial/quickstart.mdx - Basic Project: Use
templates/basic-app/ - Example Study: Review
@source/examples/memory/ - Reference: Browse
@source/examples/gallery/
Quick Start with Template
# Use our pre-configured template
cp -r templates/basic-app/ my-first-slint-app/
cd my-first-slint-app/
cargo run
Quick Start
Basic Slint Application
// Cargo.toml
[dependencies]
slint = "1.13"
// main.rs
slint::slint! {
export component AppWindow inherits Window {
Text {
text: "Hello, Slint!";
color: #3498db;
font-size: 24px;
horizontal-alignment: center;
}
}
}
fn main() -> Result<(), slint::PlatformError> {
let app = AppWindow::new()?;
app.run()
}
Project Structure
my-slint-app/
├── Cargo.toml
├── build.rs
└── src/
├── main.rs
└── ui/
└── main.slint
Core Concepts
1. Component Architecture
Component Definition
export component Button inherits Rectangle {
property <string> text: "Click me";
property <color> background-color: #3498db;
property <bool> enabled: true;
callback clicked();
background: background-color;
border-radius: 8px;
Text {
text: root.text;
color: enabled ? white : #cccccc;
horizontal-alignment: center;
vertical-alignment: center;
}
TouchArea {
enabled: root.enabled;
clicked => { root.clicked(); }
}
}
Rust Integration
slint::include_modules!();
fn main() -> Result<(), slint::PlatformError> {
let main_window = MainWindow::new()?;
let window_weak = main_window.as_weak();
main_window.on_submit_clicked(move || {
let window = window_weak.unwrap();
println!("Submit button clicked!");
});
main_window.run()
}
2. Layout Systems
VerticalLayout
export component LoginScreen inherits Window {
VerticalLayout {
spacing: 20px;
padding: 40px;
Text {
text: "Login";
font-size: 32px;
font-weight: bold;
}
TextInput {
placeholder-text: "Username";
}
TextInput {
placeholder-text: "Password";
input-type: password;
}
Button {
text: "Login";
clicked => { /* login logic */ }
}
}
}
GridLayout
export component Dashboard inherits Window {
GridLayout {
spacing: 10px;
padding: 20px;
Row[1, 2, 3] {
Column[1] {
Text { text: "Revenue"; }
Text { text: "$10,234"; font-size: 24px; }
}
}
}
}
3. Data Binding and State Management
Properties and Bindings
export component Counter inherits Window {
property <int> count: 0;
property <string> status: count > 10 ? "High" : "Low";
VerticalLayout {
Text {
text: "Count: " + count;
font-size: 24px;
}
Button {
text: "+";
clicked => { count += 1; }
}
}
}
Rust State Integration
use slint::{SharedString, ModelRc, VecModel};
fn main() -> Result<(), slint::PlatformError> {
let app = MainWindow::new()?;
let items = VecModel::from(vec![
SharedString::from("Item 1"),
SharedString::from("Item 2"),
]);
app.set_items(ModelRc::new(items));
app.run()
}
4. Styling and Themes
Custom Styling
export component ThemedApp inherits Window {
@theme.primary := #3498db;
@theme.secondary := #2ecc71;
background: @theme.background;
Text {
text: "Themed Application";
color: @theme.text;
}
Button {
text: "Primary Action";
background: @theme.primary;
}
}
5. Animations
Property Animations
export component AnimatedButton inherits Rectangle {
property <color> hover-color: #3498db;
property <length> scale: 1.0;
background: hover-color;
border-radius: 8px;
animate scale { duration: 200ms; easing: ease-out; }
animate hover-color { duration: 300ms; }
TouchArea {
mouse-entered => {
root.scale = 1.1;
root.hover-color = #2980b9;
}
mouse-exited => {
root.scale = 1.0;
root.hover-color = #3498db;
}
}
}
📚 Official Resources and Learning Materials
🎯 Primary Learning Path (Recommended)
- Official Tutorial:
@source/docs/astro/src/content/docs/tutorial/- Complete memory game tutorial - Working Examples:
@source/examples/memory/- Tutorial implementation - Component Reference:
@source/examples/gallery/- All UI components - Language Guide:
@source/docs/astro/src/content/docs/guide/language/- Complete syntax reference
📖 Official Documentation
This skill includes the complete official Slint repository as a git submodule in the source/ directory:
- 🎓 Tutorial:
@source/docs/astro/src/content/docs/tutorial/- Step-by-step learning - 📋 Language:
@source/docs/astro/src/content/docs/guide/language/- Complete language specification - 🔧 API:
@source/api/rs/slint/- Rust API documentation - 💎 Examples:
@source/examples/- Extensive working examples - 🎨 UI Libraries:
@source/ui-libraries/- Material & Fluent components
🛠️ Skill-Specific Resources
- docs/ - Navigation guide for official documentation
- examples/ - Curated learning paths with official examples
- templates/ - Ready-to-use project templates
- SOURCE_STRUCTURE.md - Complete skill structure mapping
Quick Reference
Essential APIs
slint::slint!{}- Define .slint components inlineslint::include_modules!()- Include .slint files from buildComponent::new()?- Create component instanceswindow.as_weak()- Get weak reference for callbacksModelRc::new(VecModel::from(...))- Create data models
Project Structure
my-app/
├── Cargo.toml
├── build.rs
├── src/
│ ├── main.rs
│ └── ui/
│ └── main.slint
└── assets/
├── icons/
└── images/
Common Patterns
- Use properties for component configuration
- Prefer composition over inheritance
- Use weak references for callbacks to avoid cycles
- Implement proper error handling in Rust integration
Troubleshooting
Common Issues:
- Compilation errors: Check
.slintsyntax and Rust integration - Performance issues: Optimize layout complexity and data models
- Memory leaks: Use weak references and proper cleanup
- Platform-specific bugs: Test on target platforms early
Debug Techniques:
- Use
slint::debug_log!()for logging - Enable debug mode in build configuration
- Test with different rendering backends
- Profile memory usage and rendering performance
See references/ADVANCED.md for advanced topics including custom components, performance optimization, and cross-platform development. See references/PATTERNS.md for common UI patterns like forms, navigation, and async operations.
More from straydragon/my-claude-skills
rust-cli-tui-developer
Expert guidance for Rust CLI and TUI development with official examples from clap, inquire, and ratatui libraries. Use when building command-line interfaces, terminal user interfaces, or console applications in Rust. Provides structured patterns, best practices, and real code implementations from official sources.
11feishu-openapi-dev
Expert guidance for Feishu (飞书) / Lark OpenAPI Python development. Build Feishu applications, robots, handle event subscriptions, card callbacks, and API integrations. Use when working with Feishu SDK, lark-oapi, building Feishu bots, or mentioning 飞书 development.
10mermaid-expert
Expert guidance for Mermaid.js diagramming library. Create flowcharts, sequence diagrams, class diagrams, state diagrams, Gantt charts, git graphs, and block diagrams. Use when working with Mermaid syntax, creating diagrams, or visualizing complex concepts and workflows.
4agent-skills-expert
Expert for creating and managing Claude Code Agent Skills. Create skills with git submodule + sparse-checkout for source references, write SKILL.md with proper frontmatter, and follow best practices. Use when creating new skills, adding source references to skills, or managing skill configurations.
4ui-ux-pro-max
UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient.
3uv-expert
Expert guidance for uv Python package and project manager. Use when working with uv, Python dependency management, project setup, virtual environments, or when users mention uv commands, pip alternatives, or fast Python package management.
2