Lesson 48 +20 XP

Interactivity & SVG Cheatsheet

Interactivity & SVG Cheatsheet

Cursor & selection

GoalClasses
Clickablecursor-pointer
Disabledcursor-not-allowed
Textcursor-text
Grabcursor-grab
No selectionselect-none
Select all on clickselect-all

Pointer & scroll

GoalClasses
Ignore clickspointer-events-none
Smooth scrollscroll-smooth
Scroll margin topscroll-mt-24
Snap horizontallysnap-x snap-mandatory

Forms

GoalClasses
Focus ringfocus:ring-2 focus:ring-sky-500
Keyboard onlyfocus-visible:ring-2
Placeholder stylingplaceholder:italic placeholder:text-gray-400
Accent coloraccent-sky-500
Caret colorcaret-sky-500
Disabled statedisabled:opacity-50
Invalid stateinvalid:border-red-500

Accessibility

GoalClasses
Screen-reader onlysr-only
Respect reduced motionmotion-reduce:hidden
Animate only if safemotion-safe:animate-pulse

SVG

GoalClasses
Icon sizesize-5
Fill colorfill-sky-500
Inherit colorfill-current
Stroke colorstroke-sky-500
Stroke widthstroke-2

TL;DR

  • cursor-pointer + focus-visible:ring-2 for buttons.
  • sr-only for accessible labels.
  • motion-reduce: respects user preferences.
  • size-5 fill-current is the standard icon recipe.