Build your first Hux UI app in 5 minutes
Install Hux UI
flutter pub add hux
Configure Themes
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(), ); } }
Build Your First UI
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), HuxInput( 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, ), ), ], ), ], ), ), ); } }
Run Your App
flutter run
Form Building
Form( key: _formKey, child: Column( children: [ HuxInput( label: 'Email', hint: 'Enter your email', validator: (value) { if (value?.isEmpty ?? true) { return 'Email is required'; } return null; }, ), SizedBox(height: 16), HuxButton( onPressed: () { if (_formKey.currentState!.validate()) { // Form is valid } }, child: Text('Submit'), ), ], ), )
Loading States
HuxLoadingOverlay( isLoading: _isLoading, message: 'Processing...', child: Column( children: [ HuxButton( onPressed: _isLoading ? null : _handleSubmit, isLoading: _isLoading, child: Text('Submit'), ), // Or standalone loading if (_isLoading) HuxLoading(size: HuxLoadingSize.medium), ], ), )
Theme Customization
HuxButton( onPressed: () {}, child: Text('Custom Color'), variant: HuxButtonVariant.primary, primaryColor: Colors.purple, // Custom primary color ) // Or use design tokens Container( color: HuxTokens.surfaceElevated(context), child: Text( 'Themed content', style: TextStyle(color: HuxTokens.textPrimary(context)), ), )
Data Display
Column( children: [ HuxChart.line( data: [ {'x': 1, 'y': 10}, {'x': 2, 'y': 20}, {'x': 3, 'y': 15}, ], xField: 'x', yField: 'y', title: 'Sales Data', ), SizedBox(height: 20), Row( children: [ HuxBadge( label: 'New', variant: HuxBadgeVariant.primary, ), SizedBox(width: 8), HuxBadge( label: 'Success', variant: HuxBadgeVariant.success, ), ], ), ], )