# Interactive Tutorial Guide - New York Theme Components ## 🎯 Overview This comprehensive tutorial guide will walk you through building interactive applications using the New York theme variants of our Leptos shadcn/ui components. You'll learn how to create engaging user interfaces with proper state management, form validation, and component interactions. ## 📚 Table of Contents 1. [Getting Started](#getting-started) 2. [Component Basics](#component-basics) 3. [State Management](#state-management) 4. [Form Handling](#form-handling) 5. [Interactive Features](#interactive-features) 6. [Advanced Patterns](#advanced-patterns) 7. [Best Practices](#best-practices) 8. [Troubleshooting](#troubleshooting) ## 🚀 Getting Started ### Prerequisites Before starting this tutorial, make sure you have: - Rust 1.70+ installed - Leptos 0.8+ framework - Basic understanding of Rust and Leptos - Familiarity with HTML/CSS concepts ### Project Setup 1. **Create a new Leptos project:** ```bash cargo new my-leptos-app --bin cd my-leptos-app ``` 2. **Add dependencies to Cargo.toml:** ```toml [dependencies] leptos = "0.8" leptos-shadcn-button = "0.8" leptos-shadcn-card = "0.8" leptos-shadcn-input = "0.8" leptos-shadcn-form = "0.8" ``` 3. **Import New York theme components:** ```rust use leptos_shadcn_button::new_york::{Button as ButtonNewYork, ButtonVariant as ButtonVariantNewYork}; use leptos_shadcn_card::new_york::{Card as CardNewYork, CardHeader as CardHeaderNewYork}; use leptos_shadcn_input::new_york::Input as InputNewYork; ``` ## 🧩 Component Basics ### Button Components The New York theme provides several button variants with consistent styling: ```rust #[component] pub fn ButtonShowcase() -> impl IntoView { view! {
"This is the main content of the card."
"Double: " {double_count}
"Hello, " {move || if name.get().is_empty() { "Anonymous".to_string() } else { name.get() }} "!"
"Name: " {user.name}
"Email: " {user.email}
"Theme: " {user.preferences.theme}
"No user logged in"
"Thank you for your message. We'll get back to you soon."
{move || {
let data: Vec = fields.get().into_iter()
.map(|f| format!(" {}: \"{}\"", f.label, f.value))
.collect();
format!("{{\n{}\n}}", data.join(",\n"))
}}
{modal_content.get()}
// Modal form (if needed) {move || if modal_content.get().contains("form") { view! {{notification.message}
{notification.timestamp.format("%H:%M:%S").to_string()}
"Name: " {move || data.get().name}
"Email: " {move || data.get().email}