UI Elements Lab · Newcomer → Expert

Frontend UI elements — interactive school

Learn the names, jobs, states, and “agent language” for the controls that make web apps feel real. Examples draw from your Map Builder when useful, but the catalog is wider than this repo.

NEWCOMER

See it, click it, learn its name.

FLUENT

Know variants, states, and when to use which.

EXPERT

Accessibility, design systems, precise agent prompts.

How to study

  1. Open each module. Play with every live demo.
  2. Read the Say to an agent box — copy those phrases later.
  3. Do the quiz. Mark progress in the sidebar (auto-saves in this browser).
  4. Finish with Mastery Challenge.

Catalog (what’s inside)

TrackModules
FoundationsAnatomy & states · Tokens & hierarchy
ActionsButtons · Links vs buttons · Segmented & icon actions
InputsText fields · Choice controls · Sliders · Files & colour
FeedbackBadges & chips · Progress & loading · Toasts & alerts
ContainersTabs & accordion · Modal · Drawer · Tooltip & popover
NavigationNav patterns · Steps & pagination
Data & mapsTables & toolbars · Map UI (repo-flavoured)
ExpertAccessibility · Design systems · Mastery
Mental model: every control has anatomy (parts), variants (looks), states (default/hover/focus/disabled/error/loading), and a job (what the user accomplishes). Experts talk in those four words.

Foundations · NEWCOMER

Anatomy & interactive states

Before names of widgets, learn the shared language of “how a control behaves.”

WordMeaningExample
AffordanceLooks like you can use itRaised button vs plain text
Hit targetClickable/tappable area (aim ≥44×44px on touch)Icon button padding
Focus ringOutline for keyboard usersTab into a field
FeedbackUI answers your actionToast, spinner, colour change
HierarchyWhat looks most importantPrimary vs ghost button

State matrix (live)

Same button, different states — experts always specify which state they mean.

Button stateshover · focus · active · disabled · loading
Default
Hover me
Focus (Tab)
Disabled
Loading
Also learn: error, success, selected / pressed, read-only, empty.
Say to an agent“Add a loading state to the Generate map button: disable click, show spinner, keep layout width stable (no jump).”
What is a focus ring for?
Focus rings are an accessibility essential — never remove them without an equal replacement.

Foundations · FLUENT

Design tokens & visual hierarchy

Tokens are named design decisions. Hierarchy decides what the eye notices first.

Your builder-style tokens (live)
--olive primary --amber accent --paper surface --bad danger --muted

Roles beat raw hex: say “use danger token” not “make it that red.”

:root {
  --olive: #6b8e23;   /* primary action */
  --paper: #f6f5ef;   /* page surface */
  --ink: #23281f;     /* body text */
  --line: #e1dfcf;    /* borders */
}
In your repoindex.html defines these in :root. Asking agents to “keep olive/paper tokens” stops random purple themes.

Hierarchy recipe

  • One primary action per view region (e.g. Generate map)
  • Secondary for safe alternatives (Cancel, Export CSV)
  • Ghost/tertiary for low emphasis
  • Danger only for destructive actions
Say to an agent“Don’t invent new colours — extend existing CSS variables. Primary CTA uses --olive; destructive uses --bad.”

Actions · NEWCOMER

Buttons

A button performs an action on this page. Master variants first — they are half of all UI talk.

Live variants click each
Click a button — feedback appears here.
VariantJobRepo-ish example
PrimaryMain thing to doGenerate map / Send to builder
SecondaryAlternative, saferExport CSV, Cancel
Ghost / tertiaryLow emphasis“Other input methods”
DangerDestructiveClear all pins
Icon buttonCompact toolbar actionSave draft floppy, What's new bell
FABFloating dominant action (mobile)Rare in your maps; common in mobile apps
Icon button & FAB
Expert: Prefer <button type="button"> inside forms so it doesn’t submit. Icon-only buttons need aria-label. Don’t use disabled to hide permission errors without explanation.
Say to an agent“Add a ghost button under the GI card labelled Other input methods that expands CSV + grid. Keep primary Add markers on map unchanged.”
How many primary buttons should a focused section usually have?
One primary keeps hierarchy clear. Secondaries can sit beside it.

Actions · FLUENT

Segmented controls & toggle buttons

Pick one option from a small set — like Pest Control vs Public Cleansing on your start card.

Segmented control

Selected: pest

Toolbar toggle buttons (map tools)
Repo echo: Measure & Annotate toolbar — tools are toggle buttons with pressed state.
Say to an agent“Use a segmented control for Pest vs Cleansing (not two separate pages). Pressed segment must have aria-pressed and visible selected style.”

Inputs · NEWCOMER

Text fields & forms anatomy

Label + control + helper/error text. Experts never ship a placeholder-only field.

Field anatomy
Helper text — guidance before error.
Textarea = multi-line text.
TypeUse
textGeneral words (street, landmark)
searchQuery boxes (LandsD location search)
numberRAR %, counts — still validate yourself
passwordSecrets (inbox token page)
email / tel / urlHints mobile keyboards
textareaFeedback comment, remarks
Expert: Placeholder is not a label. Required fields need visible *. Associate errors with aria-invalid and aria-describedby.
Say to an agent“Feedback form: label above each input, helper under comment, error text in --bad colour with aria-invalid on the field.”

Inputs · NEWCOMER

Checkbox, radio, switch

Three cousins — wrong choice confuses users and agents.

Live comparison


ControlQuestion it answers
Checkbox“Which of these apply?” (0…many)
Radio“Which one option?” (exactly one in a group)
Switch“Is this setting on?” (immediate toggle)
Radios vs segmented control: radios for forms with labels/help; segmented for compact toolbars/filters.
GI “All Rounds” should be which?
All Rounds is an additive filter flag — checkbox/switch territory.

Inputs · FLUENT

Sliders, steppers & numeric entry

Sliders are great for approximate values; number fields for exact ones. Sometimes you offer both.

Range slider
min / max / step are the expert attributes
Numeric stepper pattern
e.g. RAR band cut idea
Repo echo: RAR colour bands use a custom draggable strip with handles — a specialised dual-range metaphor. When talking to agents say “band cut drag handles,” not only “slider.”
Expert: Dual-range (min–max) isn’t native everywhere — often custom. Always expose typed values for precision. Keyboard: arrows should nudge step.
Say to an agent“Add a zoom preference slider 10–18 with live value label; also allow typing the number for precision.”

Inputs · FLUENT

File upload, dropzones & colour pickers

Your builder lives on CSV dropzones and colour swatches — learn the vocabulary.

Dropzone
Drop CSV here or click to choose
No file yet
Colour swatches + native picker
#00897b
Repo: legend swatches recolour markers; department badge colour UI; GI area colours.
Say to an agent“Keep dashed dropzone affordance for CSV. Clicking a legend swatch opens preset colours plus a custom colour input.”

Inputs · FLUENT

Select, listbox, combobox

Different words for “choose from a list” — precision matters at expert level.

Native select
TermMeaning
Select / dropdownNative or custom single choice menu
ListboxVisible list; often multi-select (RAR Phase listbox)
ComboboxType-ahead + list (searchable select)
MenuActions list (not for choosing form data)
AutocompleteSuggestions while typing (location search)
Repo: RAR filter “Phase” control is described as a listbox (Off / All / multi-select). LandsD search behaves like autocomplete.
Say to an agent“Phase filter should be a multi-select listbox with Off / All / individual phases — not a single native <select>.”

Feedback · NEWCOMER

Badges, chips, tags, pills

Small labeled bits. Easy to confuse — here’s the split.

Badges (status / count)
Beta Saved 3 unread Header RAS 12
Filter chips (toggle) & input tags
TP_001
NameJob
BadgeNon-click status or count
Chip / pill / tagCompact choice, filter, or removable item
Dot / status indicatorTiny presence (unread red dot on bell)
Your builder: unread red dot on What's new; header count badges for layers; department colour “badges” on markers.

Feedback · FLUENT

Progress, spinners, skeletons

Waiting without feedback feels broken. Experts choose the right wait pattern.

Patterns
Determinate progress
Indeterminate spinner — unknown duration
Skeleton — placeholder shapes while content loads
Say to an agent“While APP_CONFIG exports, disable the button and show a spinner on it; don’t block the whole page with a modal unless export takes >2s.”

Feedback · FLUENT

Toasts, alerts, banners, empty states

Different urgency → different furniture.

Toast (temporary)
Alerts / banners (persistent until dismissed)
ℹ️ Info: Draft not saved — refresh clears the workbench.
⚠️ Warning: Some CSV rows have coordinates outside HK bounds.
⛔ Error: Template missing /*__APP_CONFIG__*/ marker.
Empty state
🗺️
No markers yet

Add pins on the map or upload a CSV to begin.

PatternWhen
Toast / snackbarBrief confirmation; auto-dismiss
Inline errorNext to the field that failed
Alert / bannerPage-level notice that can wait
Modal errorMust acknowledge before continuing (use sparingly)
Empty stateNo data yet — teach the first action
Picker validation uses highlight + toast when required cells are missing — good pairing of inline + toast.

Containers · NEWCOMER

Tabs, accordion, disclosure

Ways to show one chunk of content at a time without leaving the page.

Tabs
Preview markers for survey phase 1.
Accordion / disclosure
CSV upload + hand-typing grid live here — progressive disclosure.
Say to an agent“Preview panel needs layer tabs (each phase, pools, GI, All) with aria-selected. Keep Other input methods as a collapsed disclosure.”

Containers · FLUENT

Modal / dialog

A modal blocks the page until you finish a small task or dismiss it.

Try a modal
Expert checklist:
  • Role dialog + aria-modal="true"
  • Focus moves inside; Esc closes; restore focus to opener
  • Backdrop click — decide yes/no deliberately
  • Don’t stack five modals
Builder feedback opens as an overlay from the mail icon — exported maps omit it.
Say to an agent“Feedback opens in a modal dialog with Esc to close, focus trap, and primary Send + secondary Cancel.”

Containers · FLUENT

Drawer, sheet, side panel

Slides in from an edge — good for filters or mobile menus without full-page navigation.

Open a drawer
NameTypical use
DrawerLeft/right panel (nav or filters)
Bottom sheetMobile action panel from bottom
Sticky side panelYour builder preview — not an overlay, stays in layout
Your 40% sticky preview is a layout panel, not a drawer. Drawers overlay content; sticky panels push/share space.

Containers · FLUENT

Tooltip vs popover vs popup

Three different “floating bits” — map apps use all three meanings.

Tooltip (hover/focus hint)
Save draft
Popover / menu
TermMeaning
TooltipShort hint; no interactive content
PopoverSmall floating panel; may contain controls
Dropdown menuAction list in a popover
Map popupLeaflet bindPopup — info card on a marker
Map tooltipLeaflet bindTooltip — often permanent serial labels
Say to an agent“Basemap control should open on click/tap only (popover), not hover — collapse when the map is clicked.”

Navigation · NEWCOMER

Nav bars, sidebars, breadcrumbs

Navigation answers “where am I?” and “where can I go?”

Breadcrumbs
PatternJob
Top app barGlobal actions (save, import, title)
SidebarPersistent section list (this tutorial!)
BreadcrumbsHierarchy path
TabsPeer sections of same object
Bottom tab barMobile primary destinations
Your builder is mostly a single scrolling form + sticky preview — “step list” navigation, not multi-route SPA nav.

Navigation · FLUENT

Steppers, wizards & pagination

Steppers = ordered tasks. Pagination = slices of a long list.

Stepper (wizard)
1 District
2 Data
3 Colours
4 Generate
Repo: builder renumbers visible steps when mode hides irrelevant ones.
Pagination

Data · FLUENT

Tables, grids & toolbars

Spreadsheets in the browser — your picker table is a classic data grid cousin.

Compact table
Camera IDLatLng
TP_00122.450121114.170334
TP_00222.451002114.168881
Toolbar
Toolbar = clustered actions for the current view
Say to an agent“Picker right pane is a data table with editable cells, row delete, and a toolbar for Copy / Export CSV / Clear. Sticky header row on scroll.”

Data · EXPERT · repo-flavoured

Map-specific UI elements

Leaflet apps add their own control vocabulary on top of normal UI.

Mini map + legend + zoom affordances
ElementLanguage to use
Basemap layers controlTile layer switcher; click-to-expand
MarkerPoint symbol; divIcon / SVG glyph
PopupClick card on marker
Tooltip / labelPermanent serial / RAR% label
Cluster / spiderfyGroup overlaps; explode on click
LegendKey; swatches may be interactive
Measure toolbarDist/Area + annotation tools
Locate controlGeolocation / “my location”
Scale barDistance legend on map
Hash share stateURL encodes view/filters
Exhibits: map_template.html, measure_toolbar_lab.html, coord_picker.html (65/35 map-table split).

Expert · EXPERT

Accessibility (a11y) essentials

If you can name these, agents take you seriously — and users with keyboards/screen readers survive.

Hit target size
Too small
≥44px comfort
Contrast sketch
Good on olive Good on amber Poor grey on white
ConceptWhat to say
Focus orderTab moves in logical reading order
aria-labelName for icon-only controls
aria-expandedDisclosure / accordion open state
aria-pressedToggle button on/off
aria-liveRegion that announces toasts/errors
Roledialog, tablist, toolbar, menu…
Reduced motionRespect prefers-reduced-motion
Icon-only save button needs…
Screen readers need a name. Title attribute is a weak substitute.

Expert · EXPERT

Design systems & component language

A design system is a shared kit: tokens + components + rules. Your repo is a lightweight one.

PhraseMeaning
ComponentReusable UI unit (Button, Field, Toast)
VariantLook option (primary/secondary)
Sizesm / md / lg density
CompositionHow components combine into a screen
DensityComfortable vs compact spacing
ResponsiveAdapts to viewport (your 900px breakpoint)
Progressive disclosureHide advanced until needed
Optimistic UIShow success before server confirms (advanced)
Design debtInconsistent one-off styles
Agent prompt template
On [screen/file], change [component] to [variant/state].
Keep tokens [--olive…]. Mobile: [breakpoint behaviour].
A11y: [focus / aria]. Don’t alter [constraint].
Libraries you’ll hear: Bootstrap, Material, Ant Design, shadcn/ui, Radix — different kits, same component names you’re learning here. Your project is mostly custom plain CSS, which is fine.

Capstone · EXPERT

Mastery challenge

Score these scenarios. Each is how real product talk sounds.

1. User must confirm “Clear all pins”. Best pattern?
Destructive + irreversible → confirm in a dialog.
2. Builder preview stays visible while scrolling the form. Name it:
Sticky panel ≠ overlay drawer.
3. Basemap list should open on tap and close when map clicked:
That’s your layers control behaviour.
4. “All Rounds” GI filter is best as:
Boolean filter flag.
5. Expert request — pick the strongest prompt:
Where + behaviour + constraint + viewport = expert.
Answer all quizzes in this lab — your sidebar progress shows coverage. Revisit any module that still feels fuzzy.
Quick “I can explain…” checklist

Reference

UI glossary (A–Z)

Filter as you talk with agents.

Accordion
Stacked expand/collapse sections
Affordance
Cue that something is interactive
Alert / banner
Persistent page message
Autocomplete
Suggestions while typing
Badge
Status or count label
Breadcrumb
Hierarchy path links
Breakpoint
Width where layout changes
Chip / pill / tag
Compact filter or item
Combobox
Typeable select
Dialog / modal
Blocking overlay
Disclosure
Show/hide details control
Drawer / sheet
Edge-sliding panel
Dropdown
Collapsible menu or select
Empty state
UI when there’s no data
FAB
Floating action button
Focus ring
Keyboard highlight
Ghost button
Low-emphasis outlined/text button
Hit target
Clickable area size
Icon button
Action with icon, little/no text
Legend
Map key for symbols/colours
Listbox
Selectable list (often multi)
Popover
Floating panel with content
Progress
Determinate completion bar
Radio group
Choose exactly one
Range / slider
Pick value along a continuum
Segmented control
Compact mutually exclusive choices
Skeleton
Loading placeholder shapes
Snackbar / toast
Temporary feedback message
Stepper
Ordered wizard steps
Switch
Immediate on/off
Tab
Peer panel switcher
Token
Named design value
Toolbar
Cluster of actions
Tooltip
Short hover/focus hint
Variant
Style option of a component