tailwindcss_build 0.4.0 copy "tailwindcss_build: ^0.4.0" to clipboard
tailwindcss_build: ^0.4.0 copied to clipboard

A comprehensive Flutter package that brings the power and convenience of Tailwind CSS utility classes to Flutter development.

TailwindCSS Build for Flutter #

pub package License: MIT Flutter

English | 中文 | 日本語

Transform your Flutter development with the power and elegance of Tailwind CSS utility classes through our revolutionary Builder Pattern architecture.

🚨 Pre-1.0.0 Notice #

Important: This package is in active development toward version 1.0.0. We may introduce breaking changes, deprecate APIs, or make architectural improvements to provide the best possible solution.

Current Status: The builder pattern implementations (ContainerBuilder, TextBuilder, FlexBuilder) in v0.4.0 are production-ready and represent the future direction of this library.

✨ Why TailwindCSS Build? #

🎯 Before vs After Comparison #

🔥 Simple Button Example

Traditional Flutter Way (Verbose):

GestureDetector(
  onTap: () => print('Button clicked!'),
  child: Container(
    padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
    decoration: BoxDecoration(
      color: Color(0xFF2563EB), // blue-600
      borderRadius: BorderRadius.circular(8),
      boxShadow: [
        BoxShadow(
          color: Colors.black.withOpacity(0.1),
          blurRadius: 4,
          offset: Offset(0, 2),
        ),
      ],
    ),
    child: Text(
      'Click Me',
      style: TextStyle(
        color: Colors.white,
        fontWeight: FontWeight.w500,
      ),
    ),
  ),
)

TailwindCSS Build Way (Elegant):

Text('Click Me')
    .asText()
    .textWhite()
    .fontMedium()
    .asContainer()
    .px6()
    .py3()
    .bgBlue600()
    .r8()
    .shadow()
    .onTap(() => print('Button clicked!'))

Result: ✨ 70% less code, 100% more readable!

🎨 Card Layout Example

Traditional Flutter Way:

Container(
  padding: EdgeInsets.all(24),
  decoration: BoxDecoration(
    color: Colors.white,
    borderRadius: BorderRadius.circular(12),
    boxShadow: [
      BoxShadow(
        color: Colors.black.withOpacity(0.1),
        blurRadius: 10,
        offset: Offset(0, 4),
      ),
    ],
  ),
  child: Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      Text(
        'Card Title',
        style: TextStyle(
          fontSize: 20,
          fontWeight: FontWeight.bold,
          color: Color(0xFF111827), // gray-900
        ),
      ),
      SizedBox(height: 8),
      Text(
        'Card content goes here...',
        style: TextStyle(
          fontSize: 16,
          color: Color(0xFF4B5563), // gray-600
        ),
      ),
    ],
  ),
)

TailwindCSS Build Way:

[
  Text('Card Title')
      .asText()
      .textXl()
      .fontBold()
      .textGray900()
      .build(),
  SizedBox(height: 8),
  Text('Card content goes here...')
      .asText()
      .textBase()
      .textGray600()
      .build(),
].asFlex()
    .flexCol()
    .itemsStart()
    .asContainer()
    .bgWhite()
    .p6()
    .r12()
    .shadowMd()
    .build()

Result: ✨ Self-documenting code with visual clarity!

🔄 Complex Responsive Layout Example

Traditional Flutter Way:

Container(
  padding: EdgeInsets.all(16),
  color: Color(0xFFF3F4F6), // gray-100
  child: Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    crossAxisAlignment: CrossAxisAlignment.stretch,
    children: [
      Expanded(
        child: Container(
          padding: EdgeInsets.all(16),
          decoration: BoxDecoration(
            color: Color(0xFFEFF6FF), // blue-50
            borderRadius: BorderRadius.circular(8),
          ),
          child: Text(
            'Left Panel',
            style: TextStyle(
              color: Color(0xFF1E40AF), // blue-700
              fontWeight: FontWeight.w500,
            ),
          ),
        ),
      ),
      SizedBox(width: 16),
      Expanded(
        child: Container(
          padding: EdgeInsets.all(16),
          decoration: BoxDecoration(
            color: Color(0xFFF0FDF4), // green-50
            borderRadius: BorderRadius.circular(8),
          ),
          child: Text(
            'Right Panel',
            style: TextStyle(
              color: Color(0xFF15803D), // green-700
              fontWeight: FontWeight.w500,
            ),
          ),
        ),
      ),
    ],
  ),
)

TailwindCSS Build Way:

[
  Text('Left Panel')
      .asText()
      .textBlue700()
      .fontMedium()
      .asContainer()
      .bgBlue50()
      .p4()
      .r8()
      .wFull()
      .build(),
  Text('Right Panel')
      .asText()
      .textGreen700()
      .fontMedium()
      .asContainer()
      .bgGreen50()
      .p4()
      .r8()
      .wFull()
      .build(),
].asFlex()
    .flexRow()
    .justifyBetween()
    .itemsStretch()
    .asContainer()
    .bgGray100()
    .p4()
    .build()

Result: ✨ Visual code structure matches UI layout!

🏗️ Revolutionary Architecture #

🎯 Builder Pattern Benefits #

  • 🚀 Performance: Single widget creation instead of nested containers
  • 🔗 Chainable: Intuitive method chaining for complex styling
  • 🛡️ Type Safe: Full compile-time checking with Flutter's type system
  • 💾 Memory Efficient: Reduced widget tree depth and improved rendering

🧩 Three Core Builders #

Builder Purpose Usage
TextBuilder Text styling & typography Text('Hello').asText().textBlue600().fontBold().build()
ContainerBuilder Layout, spacing & visual effects .asContainer().px6().py3().bgWhite().r8().shadow().build()
FlexBuilder Layout management (Row/Column) [widgets].asFlex().flexRow().justifyCenter().asContainer().build()

🚀 Quick Start #

Installation #

dependencies:
  tailwindcss_build: ^0.4.0

Import #

import 'package:tailwindcss_build/tailwindcss_build.dart';

Basic Usage Patterns #

📝 Text Styling
// Basic text styling
Text('Hello World')
    .asText()
    .textBlue600()    // Color
    .textXl()         // Size
    .fontBold()       // Weight
    .build()

// From string directly
'Hello World'
    .asText()
    .textWhite()
    .fontMedium()
    .textCenter()
    .build()
🎯 Container Styling
// Basic container
Text('Content')
    .build()
    .asContainer()
    .px6()           // Horizontal padding
    .py3()           // Vertical padding
    .bgBlue600()     // Background color
    .r8()            // Border radius
    .shadow()        // Drop shadow
    .build()

// Direct from text builder
Text('Styled Text')
    .asText()
    .textWhite()
    .fontMedium()
    .asContainer()   // Auto-builds text and wraps in container
    .px4()
    .py2()
    .bgRed500()
    .r6()
    .build()
🔄 Flex Layouts
// Row layout
[
  Text('Item 1').build(),
  Text('Item 2').build(),
  Text('Item 3').build(),
].asFlex()
    .flexRow()          // Direction
    .justifyCenter()    // Main axis alignment
    .itemsCenter()      // Cross axis alignment
    .asContainer()      // Convert to container for styling
    .bgGray100()
    .p4()
    .r8()
    .build()

// Column layout
[
  Text('Title').build(),
  Text('Subtitle').build(),
].asFlex()
    .flexCol()
    .itemsStart()
    .asContainer()
    .bgWhite()
    .p6()
    .shadowMd()
    .build()
🎮 Interactive Elements
// Clickable button
Text('Click Me')
    .asText()
    .textWhite()
    .fontMedium()
    .asContainer()
    .px6()
    .py3()
    .bgBlue600()
    .r8()
    .shadow()
    .onTap(() {
      print('Button clicked!');
    })

// No manual GestureDetector needed!

🎨 Complete Color System #

🌈 All TailwindCSS Colors Available #

Background Colors (21 color families)
// Basic colors
.bgWhite()      .bgBlack()      .bgTransparent()

// Gray family (50-950)
.bgGray50()     .bgGray100()    .bgGray200()    ...    .bgGray950()

// All color families with full ranges:
.bgSlate50()    →  .bgSlate950()     // Slate
.bgZinc50()     →  .bgZinc950()      // Zinc  
.bgNeutral50()  →  .bgNeutral950()   // Neutral
.bgStone50()    →  .bgStone950()     // Stone
.bgRed50()      →  .bgRed950()       // Red
.bgOrange50()   →  .bgOrange950()    // Orange
.bgAmber50()    →  .bgAmber950()     // Amber
.bgYellow50()   →  .bgYellow950()    // Yellow
.bgLime50()     →  .bgLime950()      // Lime
.bgGreen50()    →  .bgGreen950()     // Green
.bgEmerald50()  →  .bgEmerald950()   // Emerald
.bgTeal50()     →  .bgTeal950()      // Teal
.bgCyan50()     →  .bgCyan950()      // Cyan
.bgSky50()      →  .bgSky950()       // Sky
.bgBlue50()     →  .bgBlue950()      // Blue
.bgIndigo50()   →  .bgIndigo950()    // Indigo
.bgViolet50()   →  .bgViolet950()    // Violet
.bgPurple50()   →  .bgPurple950()    // Purple
.bgFuchsia50()  →  .bgFuchsia950()   // Fuchsia
.bgPink50()     →  .bgPink950()      // Pink
.bgRose50()     →  .bgRose950()      // Rose
Border Colors (All families)
// Default border (gray-200)
.border()

// Colored borders
.border().borderBlue500()
.border().borderRed300()
.border().borderGreen600()

// Custom border color
.border(color: Colors.purple)

// All border color families available:
.borderGray50()   →  .borderGray950()
.borderBlue50()   →  .borderBlue950()
.borderRed50()    →  .borderRed950()
// ... all 21 color families

📚 Advanced Examples #

🏢 Dashboard Layout
[
  // Header
  Text('Dashboard')
      .asText()
      .text2xl()
      .fontBold()
      .textGray900()
      .asContainer()
      .px6()
      .py4()
      .bgWhite()
      .borderB()
      .borderGray200()
      .build(),
  
  // Content area
  [
    // Sidebar
    [
      Text('Navigation').build(),
      Text('Menu Item 1').build(),
      Text('Menu Item 2').build(),
    ].asFlex()
        .flexCol()
        .itemsStart()
        .asContainer()
        .bgGray50()
        .p4()
        .w64()
        .build(),
    
    // Main content
    Text('Main Content Area')
        .asContainer()
        .bgWhite()
        .p6()
        .wFull()
        .build(),
  ].asFlex()
      .flexRow()
      .itemsStretch()
      .asContainer()
      .hFull()
      .build(),
].asFlex()
    .flexCol()
    .asContainer()
    .hFull()
    .bgGray100()
    .build()
💳 Product Card
[
  // Product image placeholder
  Container(height: 200, color: Colors.grey[300]),
  
  // Product info
  [
    Text('Product Name')
        .asText()
        .textLg()
        .fontSemibold()
        .textGray900()
        .build(),
    
    Text('\$29.99')
        .asText()
        .textXl()
        .fontBold()
        .textGreen600()
        .build(),
    
    Text('Product description goes here...')
        .asText()
        .textSm()
        .textGray600()
        .build(),
    
    // Action buttons
    [
      Text('Add to Cart')
          .asText()
          .textWhite()
          .fontMedium()
          .asContainer()
          .px4()
          .py2()
          .bgBlue600()
          .r6()
          .onTap(() {}),
          
      Text('♡')
          .asText()
          .textGray400()
          .asContainer()
          .px3()
          .py2()
          .border()
          .borderGray300()
          .r6()
          .onTap(() {}),
    ].asFlex()
        .flexRow()
        .justifyBetween()
        .itemsCenter()
        .build(),
  ].asFlex()
      .flexCol()
      .itemsStart()
      .asContainer()
      .p4()
      .build(),
].asFlex()
    .flexCol()
    .asContainer()
    .bgWhite()
    .r12()
    .shadowLg()
    .build()
📱 Mobile-First Form
[
  Text('Sign Up')
      .asText()
      .text2xl()
      .fontBold()
      .textCenter()
      .textGray900()
      .build(),
  
  SizedBox(height: 24),
  
  // Email input
  TextFormField(
    decoration: InputDecoration(
      hintText: 'Enter your email',
      border: OutlineInputBorder(),
    ),
  ).asContainer()
      .px4()
      .py2()
      .bgWhite()
      .border()
      .borderGray300()
      .r8()
      .build(),
  
  SizedBox(height: 16),
  
  // Password input
  TextFormField(
    obscureText: true,
    decoration: InputDecoration(
      hintText: 'Enter your password',
      border: OutlineInputBorder(),
    ),
  ).asContainer()
      .px4()
      .py2()
      .bgWhite()
      .border()
      .borderGray300()
      .r8()
      .build(),
  
  SizedBox(height: 24),
  
  // Submit button
  Text('Create Account')
      .asText()
      .textWhite()
      .fontMedium()
      .textCenter()
      .asContainer()
      .px6()
      .py3()
      .bgBlue600()
      .r8()
      .shadow()
      .wFull()
      .onTap(() {}),
      
].asFlex()
    .flexCol()
    .asContainer()
    .bgGray50()
    .p6()
    .wFull()
    .build()

🎯 Performance & Best Practices #

⚡ Performance Benefits #

Widget Tree Optimization

Before (Multiple nested containers):

Container
  └── Container (padding)
      └── Container (background)
          └── Container (border)
              └── Container (shadow)
                  └── Text

After (Single optimized container):

Container (all properties merged)
  └── Text

Result: 🚀 5x fewer widgets, 3x faster rendering

🛡️ Type Safety & IntelliSense #

// Full autocompletion support
Text('Hello')
    .asText()
    .text     // ← Shows: textXs, textSm, textBase, textLg...
    .font     // ← Shows: fontThin, fontLight, fontNormal...
    .asContainer()
    .bg       // ← Shows: bgWhite, bgBlack, bgGray50...
    .p        // ← Shows: p1, p2, p3, px2, py4...
// Optimal chaining pattern
Text('Text')
    .asText()           // 1. Convert to text builder
    .textXl()           // 2. Text-specific styles
    .fontBold()         // 
    .textBlue600()      // 
    .asContainer()      // 3. Convert to container builder
    .px6()              // 4. Spacing
    .py3()              // 
    .bgWhite()          // 5. Background
    .border()           // 6. Border
    .borderGray300()    // 
    .r8()               // 7. Border radius
    .shadow()           // 8. Effects
    .build()            // 9. Final build

🔄 Migration Guide #

From 0.3.x to 0.4.0 #

API Changes
// ❌ Old way (0.3.x)
Text('Hello').textBlue600().fontBold().asContainer().px4().bgWhite()

// ✅ New way (0.4.0)
Text('Hello')
    .asText()
    .textBlue600()
    .fontBold()
    .asContainer()
    .px4()
    .bgWhite()
    .build()

// ❌ Old method names
.asTextBuilder()  →  .asText()
.asContainerBuilder()  →  .asContainer()

// ✅ Simplified interactions
// Old: GestureDetector(onTap: ..., child: widget)
// New: widget.onTap(...)

🧪 Testing & Debugging #

🔍 Widget Inspector Integration #

// Each builder creates a single, inspectable widget
Text('Debug Me')
    .asText()
    .textRed600()
    .asContainer()
    .px4()
    .py2()
    .bgRed100()
    .border()
    .borderRed500()
    .r4()
    .build() // ← Single Container widget in inspector tree

🎨 Custom Extensions #

Brand Colors
// Define your brand colors
extension BrandColors on ContainerBuilder {
  ContainerBuilder bgPrimary() => backgroundColor(Color(0xFF1E40AF));
  ContainerBuilder bgSecondary() => backgroundColor(Color(0xFF7C3AED));
  ContainerBuilder bgAccent() => backgroundColor(Color(0xFF059669));
}

// Usage
Text('Brand Button')
    .asContainer()
    .px6()
    .py3()
    .bgPrimary()  // Custom brand color
    .r8()
    .build()
Custom Spacing
extension CustomSpacing on ContainerBuilder {
  ContainerBuilder pSection() => padding(EdgeInsets.all(32));
  ContainerBuilder pCard() => padding(EdgeInsets.all(16));
}

🤝 Contributing #

We welcome contributions! Since this is a pre-1.0.0 package:

  1. Check Issues: Look for existing issues or create new ones
  2. Discuss Changes: For major changes, please discuss first
  3. Follow Patterns: Use the established builder pattern architecture
  4. Add Tests: Include tests for new functionality
  5. Update Docs: Update documentation for new features

🌟 Community #

📄 License #

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments #

  • Inspired by Tailwind CSS
  • Built for the Flutter community
  • Thanks to all contributors and users

Ready to revolutionize your Flutter development?

flutter pub add tailwindcss_build

Transform verbose Flutter code into elegant, maintainable, and performant UI declarations with TailwindCSS Build.

5
likes
0
points
533
downloads

Publisher

unverified uploader

Weekly Downloads

A comprehensive Flutter package that brings the power and convenience of Tailwind CSS utility classes to Flutter development.

Repository (GitHub)
View/report issues

Topics

#tailwindcss #flutter #ui #utility-classes #widget

Funding

Consider supporting this project:

github.com

License

unknown (license)

Dependencies

flutter

More

Packages that depend on tailwindcss_build