askill
flutter-ux-rules

flutter-ux-rulesSafety 100Repository

Verifiable UX and UI rules for Flutter: touch targets, contrast, spacing, component states, accessibility, and visual consistency. Trigger: When creating UI components, reviewing screens for UX compliance, or checking accessibility standards.

0 stars
1.2k downloads
Updated 2/9/2026

Package Files

Loading files...
SKILL.md

When to Use

  • Creating any interactive UI component (buttons, inputs, cards)
  • Reviewing a screen for UX/UI compliance before PR
  • Checking accessibility standards
  • Defining spacing, sizing, or typography scales

Touch Targets

RuleMinimumApplies To
Tap area48x48 dpButtons, icons, list items, checkboxes
Spacing between targets8 dp minimumAdjacent tappable elements
Text buttons48 dp height even if text is smallerTextButton, links

Verification: Every GestureDetector or custom tappable widget MUST have at least 48x48 dp hit area. Forui's FButton and FButton.icon handle this automatically. For custom tap targets, use explicit SizedBox constraints.

Example: See assets/touch_targets.dart

Color & Contrast

All colors follow the Catppuccin palette defined in the corporate-colors skill.

RuleRequirementStandard
Normal text (< 18sp)4.5:1 contrast ratioWCAG AA
Large text (≥ 18sp or 14sp bold)3:1 contrast ratioWCAG AA
Interactive elements3:1 against backgroundWCAG AA
Focus indicators3:1 against adjacent colorsWCAG AA
Never color-onlyAlways pair color with icon/text/shapeUniversal

Verification:

  • Error states: red color + error icon + text message (never red alone)
  • Success states: green color + check icon + text message
  • Disabled states: use muted color tokens from corporate-colors

Spacing Grid

All spacing uses a 4dp base grid with an 8dp standard unit.

TokenValueUsage
space-xs4 dpTight padding inside small atoms
space-sm8 dpBetween related elements
space-md16 dpBetween sections, card padding
space-lg24 dpBetween major sections
space-xl32 dpPage padding, section gaps
space-2xl48 dpTop/bottom page margins

Rule: NEVER use arbitrary numbers. All padding, margin, and gap values must be multiples of 4.

Example: See assets/spacing_constants.dart

Component States (CRITICAL)

Every interactive component MUST implement ALL applicable states:

StateVisual ChangeRequired For
DefaultBase appearanceAll components
Pressed/ActiveDarken/lighten by 10-15%Buttons, cards, list items
DisabledReduced opacity (0.38) + no interactionAll interactive components
Focused2dp outline in primary-active colorAll interactive components
ErrorError color border + error icon + messageInputs, forms
LoadingSpinner or skeleton replacing contentAsync actions
HoverSubtle background changeWeb only (not mobile)

Verification checklist for atoms/molecules:

  • Default state looks correct
  • Disabled state removes onPressed AND visually indicates disabled
  • Error state shows error color + icon + message text
  • Loading state shows feedback (not frozen UI)
  • Pressed state gives tactile feedback (ripple or opacity)

Example: See assets/component_states.dart

Typography Scale

Use Forui's FTypography with consistent hierarchy:

StyleSizeUsage
context.theme.typography.xl436spHero text (rare)
context.theme.typography.xl224spPage titles
context.theme.typography.xl20spSection headers
context.theme.typography.lg18spCard titles
context.theme.typography.base16spPrimary body text
context.theme.typography.sm14spSecondary body text, button labels
context.theme.typography.xs12spCaptions, form labels

Rule: NEVER hardcode font sizes. Always use context.theme.typography.{scale}. Forui generates the full typography scale from your theme config.

Feedback & Loading

ScenarioRequired Feedback
Button tap (async action)Loading spinner in button, disable re-tap
Form submissionDisable form + show loading indicator
Pull to refreshNative RefreshIndicator
Empty listIllustration + message + CTA button
Error stateError message + retry button
Network errorSnackbar or inline error with retry
Successful actionSnackbar confirmation or navigation

Rule: The user must NEVER see a frozen UI. Every async action must show loading feedback within 100ms.

Accessibility

RuleRequirement
Semantic labelsAll Icon and Image widgets MUST have semanticLabel
Form labelsAll inputs MUST have visible labels (not just placeholders)
Screen readerTest with TalkBack (Android) and VoiceOver (iOS)
Text scalingUI must not break at 200% text scale
Reduce motionRespect MediaQuery.disableAnimations for essential animations
Tap target48x48 dp minimum (see Touch Targets section)

Verification: Run flutter analyze for accessibility warnings. Add Semantics widget when automatic labeling is insufficient. Forui's FLocalizations provides built-in localization support.

Form UX Rules

RuleRequirement
ValidationShow errors on field blur OR on submit, not while typing
Error positionBelow the field, in labelMedium style with error color
Required fieldsMark with asterisk (*) in label
Password fieldsToggle visibility icon, show strength indicator
Submit buttonDisabled until form is valid, shows loading on submit
KeyboardSet correct TextInputType (email, phone, number)
AutofillEnable AutofillHints for email, password, name, phone

Anti-Patterns

❌ Don't✅ Do
Hardcode colors (Color(0xFF...))Use context.theme.colors tokens
Hardcode font sizes (fontSize: 14)Use context.theme.typography
Hardcode spacing (padding: 17)Use spacing constants (multiples of 4)
Disable button without visual changeReduce opacity + change color to muted
Show only red for errorsRed + icon + text message
Frozen UI during async operationsShow loading state immediately
Placeholder-only labelsAlways show a visible label above the field
Tiny tap targets (24x24)Minimum 48x48 dp
Rely on color alone for meaningColor + icon + text (triple redundancy)

UX Review Checklist

When reviewing components or screens, use the comprehensive checklist.

See assets/ux_review_checklist.md for the full checklist.

Resources

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

87/100Analyzed 2/19/2026

Comprehensive Flutter UX/UI rules document covering touch targets (48dp), color contrast (WCAG AA), spacing grid (4dp base), component states, typography, accessibility, and form UX. Well-structured with tables, verification checklists, and clear triggers. Scores high on completeness, clarity, and actionability. Minor扣分 for project-specific references (Forui components, corporate-colors skill) but core principles are universally applicable. Located in dedicated skills folder with proper metadata and tags.

100
92
70
95
90

Metadata

Licenseunknown
Version-
Updated2/9/2026
Publisher333-333-333

Tags

testing