ERP/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv
2026-01-03 19:18:40 +08:00

11 KiB

1NoCategoryGuidelineDescriptionDoDon'tCode GoodCode BadSeverityDocs URL
21AnimationUse Tailwind animate utilitiesBuilt-in animations are optimized and respect reduced-motionUse animate-pulse animate-spin animate-pingCustom @keyframes for simple effectsanimate-pulse@keyframes pulse {...}Mediumhttps://tailwindcss.com/docs/animation
32AnimationLimit bounce animationsContinuous bounce is distracting and causes motion sicknessUse animate-bounce sparingly on CTAs onlyMultiple bounce animations on pageSingle CTA with animate-bounce5+ elements with animate-bounceHigh
43AnimationTransition durationUse appropriate transition speeds for UI feedbackduration-150 to duration-300 for UIduration-1000 or longer for UI elementstransition-all duration-200transition-all duration-1000Mediumhttps://tailwindcss.com/docs/transition-duration
54AnimationHover transitionsAdd smooth transitions on hover state changesAdd transition class with hover statesInstant hover changes without transitionhover:bg-gray-100 transition-colorshover:bg-gray-100 (no transition)Low
65Z-IndexUse Tailwind z-* scaleConsistent stacking context with predefined scalez-0 z-10 z-20 z-30 z-40 z-50Arbitrary z-index valuesz-50 for modalsz-[9999]Mediumhttps://tailwindcss.com/docs/z-index
76Z-IndexFixed elements z-indexFixed navigation and modals need explicit z-indexz-50 for nav z-40 for dropdownsRelying on DOM order for stackingfixed top-0 z-50fixed top-0 (no z-index)High
87Z-IndexNegative z-index for backgroundsUse negative z-index for decorative backgroundsz-[-1] for background elementsPositive z-index for backgrounds-z-10 for decorativez-10 for backgroundLow
98LayoutContainer max-widthLimit content width for readabilitymax-w-7xl mx-auto for main contentFull-width content on large screensmax-w-7xl mx-auto px-4w-full (no max-width)Mediumhttps://tailwindcss.com/docs/container
109LayoutResponsive paddingAdjust padding for different screen sizespx-4 md:px-6 lg:px-8Same padding all sizespx-4 sm:px-6 lg:px-8px-8 (same all sizes)Medium
1110LayoutGrid gapsUse consistent gap utilities for spacinggap-4 gap-6 gap-8Margins on individual itemsgrid gap-6grid with mb-4 on each itemMediumhttps://tailwindcss.com/docs/gap
1211LayoutFlexbox alignmentUse flex utilities for alignmentitems-center justify-betweenMultiple nested wrappersflex items-center justify-betweenNested divs for alignmentLow
1312ImagesAspect ratioMaintain consistent image aspect ratiosaspect-video aspect-squareNo aspect ratio on containersaspect-video rounded-lgNo aspect controlMediumhttps://tailwindcss.com/docs/aspect-ratio
1413ImagesObject fitControl image scaling within containersobject-cover object-containStretched distorted imagesobject-cover w-full h-fullNo object-fitMediumhttps://tailwindcss.com/docs/object-fit
1514ImagesLazy loadingDefer loading of off-screen imagesloading='lazy' on imagesAll images eager load<img loading='lazy'><img> without lazyHigh
1615ImagesResponsive imagesServe appropriate image sizessrcset and sizes attributesSame large image all devicessrcset with multiple sizes4000px image everywhereHigh
1716TypographyProse pluginUse @tailwindcss/typography for rich textprose prose-lg for article contentCustom styles for markdownprose prose-lg max-w-noneCustom text stylingMediumhttps://tailwindcss.com/docs/typography-plugin
1817TypographyLine heightUse appropriate line height for readabilityleading-relaxed for body textDefault tight line heightleading-relaxed (1.625)leading-none or leading-tightMediumhttps://tailwindcss.com/docs/line-height
1918TypographyFont size scaleUse consistent text size scaletext-sm text-base text-lg text-xlArbitrary font sizestext-lgtext-[17px]Lowhttps://tailwindcss.com/docs/font-size
2019TypographyText truncationHandle long text gracefullytruncate or line-clamp-*Overflow breaking layoutline-clamp-2No overflow handlingMediumhttps://tailwindcss.com/docs/text-overflow
2120ColorsOpacity utilitiesUse color opacity utilitiesbg-black/50 text-white/80Separate opacity classbg-black/50bg-black opacity-50Lowhttps://tailwindcss.com/docs/background-color
2221ColorsDark modeSupport dark mode with dark: prefixdark:bg-gray-900 dark:text-whiteNo dark mode supportdark:bg-gray-900Only light themeMediumhttps://tailwindcss.com/docs/dark-mode
2322ColorsSemantic colorsUse semantic color naming in configprimary secondary danger successGeneric color names in componentsbg-primarybg-blue-500 everywhereMedium
2423SpacingConsistent spacing scaleUse Tailwind spacing scale consistentlyp-4 m-6 gap-8Arbitrary pixel valuesp-4 (1rem)p-[15px]Lowhttps://tailwindcss.com/docs/customizing-spacing
2524SpacingNegative marginsUse sparingly for overlapping effects-mt-4 for overlapping elementsNegative margins for layout fixing-mt-8 for card overlap-m-2 to fix spacing issuesMedium
2625SpacingSpace betweenUse space-y-* for vertical listsspace-y-4 on flex/grid columnMargin on each childspace-y-4Each child has mb-4Lowhttps://tailwindcss.com/docs/space
2726FormsFocus statesAlways show focus indicatorsfocus:ring-2 focus:ring-blue-500Remove focus outlinefocus:ring-2 focus:ring-offset-2focus:outline-none (no replacement)High
2827FormsInput sizingConsistent input dimensionsh-10 px-3 for inputsInconsistent input heightsh-10 w-full px-3Various heights per inputMedium
2928FormsDisabled statesClear disabled stylingdisabled:opacity-50 disabled:cursor-not-allowedNo disabled indicationdisabled:opacity-50Same style as enabledMedium
3029FormsPlaceholder stylingStyle placeholder text appropriatelyplaceholder:text-gray-400Dark placeholder textplaceholder:text-gray-400Default dark placeholderLow
3130ResponsiveMobile-first approachStart with mobile styles and add breakpointsDefault mobile + md: lg: xl:Desktop-first approachtext-sm md:text-basetext-base max-md:text-smMediumhttps://tailwindcss.com/docs/responsive-design
3231ResponsiveBreakpoint testingTest at standard breakpoints320 375 768 1024 1280 1536Only test on development deviceTest all breakpointsSingle device testingHigh
3332ResponsiveHidden/shown utilitiesControl visibility per breakpointhidden md:blockDifferent content per breakpointhidden md:flexSeparate mobile/desktop componentsLowhttps://tailwindcss.com/docs/display
3433ButtonsButton sizingConsistent button dimensionspx-4 py-2 or px-6 py-3Inconsistent button sizespx-4 py-2 text-smVarious padding per buttonMedium
3534ButtonsTouch targetsMinimum 44px touch target on mobilemin-h-[44px] on mobileSmall buttons on mobilemin-h-[44px] min-w-[44px]h-8 w-8 on mobileHigh
3635ButtonsLoading statesShow loading feedbackdisabled + spinner iconClickable during loading<Button disabled><Spinner/></Button>Button without loading stateHigh
3736ButtonsIcon buttonsAccessible icon-only buttonsaria-label on icon buttonsIcon button without label<button aria-label='Close'><XIcon/></button><button><XIcon/></button>High
3837CardsCard structureConsistent card stylingrounded-lg shadow-md p-6Inconsistent card stylesrounded-2xl shadow-lg p-6Mixed card stylingLow
3938CardsCard hover statesInteractive cards should have hover feedbackhover:shadow-lg transition-shadowNo hover on clickable cardshover:shadow-xl transition-shadowStatic cards that are clickableMedium
4039CardsCard spacingConsistent internal card spacingspace-y-4 for card contentInconsistent internal spacingspace-y-4 or p-6Mixed mb-2 mb-4 mb-6Low
4140AccessibilityScreen reader textProvide context for screen readerssr-only for hidden labelsMissing context for icons<span class='sr-only'>Close menu</span>No label for icon buttonHighhttps://tailwindcss.com/docs/screen-readers
4241AccessibilityFocus visibleShow focus only for keyboard usersfocus-visible:ring-2Focus on all interactionsfocus-visible:ring-2focus:ring-2 (shows on click too)Medium
4342AccessibilityReduced motionRespect user motion preferencesmotion-reduce:animate-noneIgnore motion preferencesmotion-reduce:transition-noneNo reduced motion supportHighhttps://tailwindcss.com/docs/hover-focus-and-other-states#prefers-reduced-motion
4443PerformanceConfigure content pathsTailwind needs to know where classes are usedUse 'content' array in configUse deprecated 'purge' option (v2)content: ['./src/**/*.{js,ts,jsx,tsx}']purge: [...]Highhttps://tailwindcss.com/docs/content-configuration
4544PerformanceJIT modeUse JIT for faster builds and smaller bundlesJIT enabled (default in v3)Full CSS in developmentTailwind v3 defaultsTailwind v2 without JITMedium
4645PerformanceAvoid @apply bloatUse @apply sparinglyDirect utilities in HTMLHeavy @apply usageclass='px-4 py-2 rounded'@apply px-4 py-2 rounded;Lowhttps://tailwindcss.com/docs/reusing-styles
4746PluginsOfficial pluginsUse official Tailwind plugins@tailwindcss/forms typography aspect-ratioCustom implementations@tailwindcss/formsCustom form reset CSSMediumhttps://tailwindcss.com/docs/plugins
4847PluginsCustom utilitiesCreate utilities for repeated patternsCustom utility in configRepeated arbitrary valuesCustom shadow utilityshadow-[0_4px_20px_rgba(0,0,0,0.1)] everywhereMedium
4948LayoutContainer QueriesUse @container for component-based responsivenessUse @container and @lg: etc.Media queries for component internals@container @lg:grid-cols-2@media (min-width: ...) inside componentMediumhttps://github.com/tailwindlabs/tailwindcss-container-queries
5049InteractivityGroup and PeerStyle based on parent/sibling stategroup-hover peer-checkedJS for simple state interactionsgroup-hover:text-blue-500onMouseEnter={() => setHover(true)}Lowhttps://tailwindcss.com/docs/hover-focus-and-other-states#styling-based-on-parent-state
5150CustomizationArbitrary ValuesUse [] for one-off valuesw-[350px] for specific needsCreating config for single usetop-[117px] (if strictly needed)style={{ top: '117px' }}Lowhttps://tailwindcss.com/docs/adding-custom-styles#using-arbitrary-values
5251ColorsTheme color variablesDefine colors in Tailwind theme and use directlybg-primary text-success border-ctabg-[var(--color-primary)] text-[var(--color-success)]bg-primarybg-[var(--color-primary)]Mediumhttps://tailwindcss.com/docs/customizing-colors
5352ColorsUse bg-linear-to-* for gradientsTailwind v4 uses bg-linear-to-* syntax for gradientsbg-linear-to-r bg-linear-to-bbg-gradient-to-* (deprecated in v4)bg-linear-to-r from-blue-500 to-purple-500bg-gradient-to-r from-blue-500 to-purple-500Mediumhttps://tailwindcss.com/docs/background-image
5453LayoutUse shrink-0 shorthandShorter class name for flex-shrink-0shrink-0 shrinkflex-shrink-0 flex-shrinkshrink-0flex-shrink-0Lowhttps://tailwindcss.com/docs/flex-shrink
5554LayoutUse size-* for square dimensionsSingle utility for equal width and heightsize-4 size-8 size-12Separate h-* w-* for squaressize-6h-6 w-6Lowhttps://tailwindcss.com/docs/size
5655ImagesSVG explicit dimensionsAdd width/height attributes to SVGs to prevent layout shift before CSS loads<svg class='size-6' width='24' height='24'>SVG without explicit dimensions<svg class='size-6' width='24' height='24'><svg class='size-6'>High