Quick Setup

Get up and running with Hux UI in just a few minutes. This guide will help you create a simple Flutter app using Hux UI components.

1

Install Hux UI

Add Hux UI to your Flutter project:

flutter pub add hux
2

Configure Themes

Set up Hux UI themes in your main.dart:

main.dart
import 'package:flutter/material.dart';
import 'package:hux/hux.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Hux UI Quickstart',
      theme: HuxTheme.lightTheme,
      darkTheme: HuxTheme.darkTheme,
      home: QuickstartPage(),
    );
  }
}
3

Build Your First UI

Create a simple page with Hux UI components:

class QuickstartPage extends StatefulWidget {
  @override
  _QuickstartPageState createState() => _QuickstartPageState();
}

class _QuickstartPageState extends State<QuickstartPage> {
  bool _isLoading = false;
  final _textController = TextEditingController();
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Hux UI Quickstart')),
      body: Padding(
        padding: EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            HuxCard(
              title: 'Welcome to Hux UI',
              subtitle: 'Modern Flutter components',
              child: Text('This is your first Hux UI app!'),
            ),
            SizedBox(height: 20),
            
            HuxTextField(
              label: 'Enter your name',
              hint: 'Type here...',
              controller: _textController,
              prefixIcon: Icon(FeatherIcons.user),
            ),
            SizedBox(height: 20),
            
            HuxButton(
              onPressed: _isLoading ? null : () {
                setState(() { _isLoading = true; });
                Future.delayed(Duration(seconds: 2), () {
                  setState(() { _isLoading = false; });
                });
              },
              isLoading: _isLoading,
              child: Text('Get Started'),
              variant: HuxButtonVariant.primary,
            ),
            SizedBox(height: 20),
            
            Row(
              children: [
                Expanded(
                  child: HuxButton(
                    onPressed: () {},
                    child: Text('Secondary'),
                    variant: HuxButtonVariant.secondary,
                  ),
                ),
                SizedBox(width: 12),
                Expanded(
                  child: HuxButton(
                    onPressed: () {},
                    child: Text('Outline'),
                    variant: HuxButtonVariant.outline,
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
4

Run Your App

Start your Flutter app to see Hux UI in action:

flutter run

What You Built

Congratulations! You just created a Flutter app with:

  • HuxCard - A beautiful card container with title and subtitle
  • HuxTextField - An enhanced text input with icon and validation support
  • HuxButton - Multiple button variants with loading states
  • Automatic theming - Light and dark mode support

Common Patterns

Here are some common patterns you’ll use with Hux UI:

Next Steps

Now that you’ve built your first Hux UI app, explore more features:

Get Help

If you need assistance:

The complete source code for this quickstart example is available in the Hux UI repository examples.