wind_kit library

Wind - Utility-First Styling for Flutter

Wind is a utility-first styling framework for Flutter, inspired by TailwindCSS. It translates Tailwind-style utility class strings into Flutter widget trees, allowing you to build UIs using familiar CSS-like syntax directly in your widgets.

Core Concepts

  • Utility Classes: Style widgets using className strings like 'flex gap-4 p-6 bg-blue-500 rounded-lg'
  • W-Prefixed Widgets: Use WDiv, WText, WButton, WInput, and other W-widgets that accept className
  • Responsive Design: Apply breakpoint-specific styles with sm:, md:, lg:, xl:, 2xl: prefixes
  • State-Based Styling: Use hover:, focus:, disabled:, loading: prefixes for interactive states
  • Dark Mode: Toggle themes and use dark: prefix for dark-mode-specific styles
  • Platform-Specific: Target platforms with ios:, android:, web:, mobile: prefixes

Getting Started

import 'package:material_ui/material_ui.dart';
import 'package:wind_kit/wind_kit.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return WindTheme(
      data: WindThemeData(),
      child: MaterialApp(
        home: Scaffold(
          body: WDiv(
            className: 'flex flex-col gap-4 p-6 bg-gray-100 dark:bg-gray-900 min-h-screen',
            children: [
              WText(
                'Hello Wind!',
                className: 'text-3xl font-bold text-blue-600 dark:text-blue-400',
              ),
              WDiv(
                className: 'bg-white dark:bg-gray-800 rounded-xl shadow-lg p-6 hover:shadow-xl',
                child: WText(
                  'Build UIs faster with utility-first styling',
                  className: 'text-gray-600 dark:text-gray-300',
                ),
              ),
              WButton(
                onTap: () => debugPrint('Clicked!'),
                className: 'bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg',
                child: Text('Get Started'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

For complete documentation, visit the Wind documentation.

Classes

DateRange
Represents a date range with start and end dates.
PopoverController
Controller for programmatic popover control
SelectOption<T>
SelectOption - Data Model for WSelect
WActionHandler
Bridges JSON action definitions to Dart callback handlers in the dynamic module.
WAnchor
The Foundational State Wrapper
WBadge
A Utility-First Badge / Label Component
WBreakpoint
Declarative Breakpoint-Keyed Builder
WButton
The Utility-First Button Component
WCard
A Surface Container for Card-Style Layouts
WCheckbox
A Utility-First Checkbox Component
WDatePicker
WDatePicker - Utility-First Date Picker Component
WDiv
The Fundamental Building Block of Wind
WDynamic
Main widget for rendering dynamic UI from JSON configuration.
WDynamicConfig
Configuration for WindDynamic rendering.
WDynamicController
Controller for external access to WDynamic state.
WDynamicState
Reactive state store for dynamic widget values.
WFormCheckbox
A Wind-styled checkbox that integrates with Flutter's Form validation.
WFormDatePicker
A Wind-styled date picker that integrates with Flutter's Form validation.
WFormInput
A Wind-styled input that integrates with Flutter's Form validation.
WFormMultiSelect<T>
A Wind-styled multi-select that integrates with Flutter's Form validation.
WFormSelect<T>
A Wind-styled single-select that integrates with Flutter's Form validation.
WIcon
The Utility-First Icon Component
WImage
The Utility-First Image Component
Wind
Wind framework-level facade for debug-tooling integration.
WindAnchorState
The State Snapshot
WindAnchorStateProvider
The State Propagator
WindAnimationWrapper
Wraps a widget in the appropriate animation based on WindAnimationType.
WindCompoundVariant
A Single Compound-Variant Rule for WindRecipe
WindContext
The styling context context
WindParser
The Core Parsing Engine
WindParserInterface
Interface for specialized Wind CSS parsers.
WindPerfCounters
Opt-in aggregate counters for Wind's hottest path.
WindPerfResolverImpl
Publishes Wind's aggregate performance counters through the wind_kit_diagnostics_contracts perf slot.
WindRecipe
A Tailwind-Variants tv() Equivalent for Wind
WindSlotCompoundVariant
A Single Compound-Variant Rule for WindSlotRecipe
WindSlotRecipe
A Tailwind-Variants Multi-Part (slots) Recipe for Wind
WindStyle
The Immutable Style Object
WindTheme
The Theme Provider
WindThemeController
Theme Controller
WindThemeData
Theme Configuration
WInput
The Utility-First Input Component
WKeyboardActions
A Wind-styled wrapper that adds keyboard actions (Done button, navigation) to input fields, especially for iOS numeric keyboards.
WKeyboardToolbarInset
Publishes the height of the keyboard toolbar currently on screen.
WPopover
WPopover - Flexible Popover Component
WRadio<T>
A Utility-First Radio Button Component
WSelect<T>
The Utility-First Select Component
WSpacer
WSpacer - Lightweight Spacing Widget
WSvg
The Utility-First SVG Component
WSwitch
A Utility-First Toggle Switch Component
WTabs
A Utility-First Tabs Component
WText
The Utility-First Text Component
WTooltip
The Utility-First Tooltip

Enums

InputType
Input type enum for WInput widget
PopoverAlignment
Popover Alignment Options
WDatePickerMode
Date picker selection mode.
WindAnimationType
Animation types for animate-* classes
WindDisplayType
WindInheritedRead
The four inherited-widget reads WindPerfCounters.recordInheritedRead tracks. Backed by an enum rather than a free string so a call site cannot typo a key that would then silently sit outside the pinned four; .name is what gets written into WindPerfCounters.inheritedReads, so the stats map keys are unchanged by this type.
WindLetterSpacingUnit
The unit WindStyle.letterSpacing is written in.
WindOverflow
Overflow behavior types
WindowSizeClass
How much horizontal room the window has, in the theme's own breakpoints.
WindPositionType
Position types for positioned elements e.g., relative, absolute
WindTextTransform
WKeyboardPlatform
Platform gate for WKeyboardActions toolbar visibility.

Extensions

WindContextExtension on BuildContext
Wind Context Extensions

Constants

borderRadius → const Map<String, double>
Default border radius values for Wind theme
borderWidths → const Map<String, double>
Default border width values for Wind theme
colors → const Map<String, dynamic>
containers → const Map<String, int>
fontFamilies → const Map<String, String>
Default font family configurations for Wind theme.
fontSizes → const Map<String, double>
fontWeights → const Map<String, FontWeight>
leading → const Map<String, double>
screens → const Map<String, int>
tracking → const Map<String, double>
Letter spacing scale for tracking-*, in em: a multiple of the font size of the text it applies to, exactly Tailwind's scale. tracking-tight on 14px text is 14 * -0.025 = -0.35 logical pixels.
windPxUnit → const double
The pixel unit used for sizing calculations.
windRemUnit → const int
The REM unit used for sizing calculations.

Functions

applyOpacity(Color color, double opacity) → Color
Applies opacity to a Color.
computeAvailableHeight({required PopoverAlignment alignment, required Offset triggerPosition, required Size triggerSize, required Size screenSize, required Offset offset, double margin = 8}) → double
The height left for the overlay on the side alignment opens toward: below the trigger for a bottom alignment, above it for a top one, less margin from the viewport edge. Never negative.
computeEffectiveAlignment({required PopoverAlignment requested, required Offset triggerPosition, required Size triggerSize, required Size popoverSize, required Size screenSize, required Offset offset}) → PopoverAlignment
Computes effective alignment by flipping when overflow would occur.
computeHorizontalClamp({required PopoverAlignment alignment, required Offset triggerPosition, required Size triggerSize, required double popoverWidth, required Size screenSize, required Offset offset, double margin = 8}) → double
Computes a horizontal correction (dx) that pulls the overlay back inside the viewport when the resolved alignment would still place part of it off-screen after computeEffectiveAlignment has already swapped the anchored side.
contrastForeground(Color background, {Color light = const Color(0xFFFFFFFF), Color dark = const Color(0xFF000000)}) → Color
The more readable of light and dark on top of background, picked by comparing their actual WCAG contrast ratios against each other.
contrastRatio(Color a, Color b) → double
The WCAG 2.x contrast ratio between two colours, from 1 (identical) to 21 (black against white).
hexToColor(String code) → Color
Color Utility: Hex Parser
invertMaterialColor(MaterialColor color) → MaterialColor
Color Utility: Inverter
parseColorOpacity(String colorClass) → ({String colorPart, double? opacity})
Parses a color class with optional opacity modifier.
wColor(BuildContext context, String colorName, {int shade = 500, String? darkColorName, int darkShade = 500}) → Color?
Global Color Resolver
wFontSize(BuildContext context, String sizeName) → double?
Returns a font size by name.
wFontWeight(BuildContext context, String weightName) → FontWeight?
Returns a font weight by name.
wInheritedFontSize(BuildContext context) → double
Returns the font size text under context inherits, in logical pixels.
wrapWithAnimation({required Widget child, WindAnimationType? animationType, Duration? duration, Curve? curve}) → Widget
Helper function to wrap a widget with animation if animationType is set.
wScreen(BuildContext context, String name) → int?
Returns the pixel value for a breakpoint name.
wScreenCurrent(BuildContext context) → String
Returns the current active breakpoint name.
wScreenIs(BuildContext context, String name) → bool
Checks if the current screen width is at least the given breakpoint.
wSpacing(BuildContext context, num multiplier) → double
Returns a spacing value based on the multiplier.
wStyle(BuildContext context, String className) → WindStyle
Style Parser Helper
wWindowClassOf(BuildContext context) → WindowSizeClass
Classifies the window width against the theme's md and lg screens.

Typedefs

CreateOptionBuilder = Widget Function(BuildContext context, String query, VoidCallback onCreate)
Signature for building the "create option" button.
DateDisplayFormat = String Function(DateTime date)
Signature for custom display format function.
EmptyStateBuilder = Widget Function(BuildContext context, String query)
Signature for building the empty state.
ImageErrorBuilder = Widget Function(BuildContext context, Object error, StackTrace? stackTrace)
Signature for building a custom error widget.
ImageLoadingBuilder = Widget Function(BuildContext context, Widget child, ImageChunkEvent? loadingProgress)
Signature for building a custom loading widget.
LoadingBuilder = Widget Function(BuildContext context)
Signature for building the loading indicator.
MultiSelectTriggerBuilder<T> = Widget Function(BuildContext context, List<SelectOption<T>> selectedOptions, bool isOpen)
Signature for building a custom trigger widget for multi-select WSelect.
PopoverContentBuilder = Widget Function(BuildContext context, VoidCallback close)
Builder for the popover content.
PopoverTriggerBuilder = Widget Function(BuildContext context, bool isOpen, bool isHovering)
Builder for the trigger widget.
SelectedChipBuilder<T> = Widget Function(BuildContext context, SelectOption<T> option, VoidCallback onRemove)
Signature for building a selected chip/tag in multi-select mode.
SelectItemBuilder<T> = Widget Function(BuildContext context, SelectOption<T> option, bool isSelected, bool isHovered)
Signature for building a custom item widget for WSelect.
SelectTriggerBuilder<T> = Widget Function(BuildContext context, SelectOption<T>? selectedOption, bool isOpen)
Signature for building a custom trigger widget for WSelect.
WWidgetBuilder = Widget Function(Map<String, dynamic> props, List<Widget> children)
Builder function for custom widget types.