Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

UI elements

Practical study notes on UI elements: what they are, how to design them, key definitions and laws that affect them, worked examples, exam tips and quick checks.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

User interfaces are made of small parts called elements. An engineer uses good UI elements to make software easy, fast and safe to use — for example by choosing the right control for input, arranging elements for quick recognition, and giving clear feedback. Well-designed elements reduce user errors, speed up tasks (fewer taps/clicks) and improve accessibility.

Key ideas

Start with definitions (I define terms before using them):

  • User interface element (UI element) — a single visible, interactive or informational component on a screen (for example, a button, checkbox, text field or icon). A UI element may be interactive (accept input) or non-interactive (label, icon used only for meaning).
  • Control / widget — a UI element that accepts user input or causes actions (for example, a button, slider, checkbox, radio button, select/dropdown, text field). Use radio buttons for mutually exclusive choices and checkboxes for independent options; group related options with a visible group label (e.g., fieldset/legend on the web).
  • Affordance — the property of a UI element that suggests how it should be used. A good affordance makes the possible action obvious (e.g., a button looks pressable). When we say “affordance” we mean perceived affordance: the visual cues that tell the user what to do.
  • Feedback — information returned to the user after an action (visual, audio or haptic) that confirms system state or result (for example, a spinner while loading, a green check for success, an error message for invalid input).
  • State — the condition of an element that can change (for example, enabled/disabled, focused, hovered, pressed, selected, error). Show different states clearly.
  • Label — short text that names or describes an element. A label must be clear and placed near its control (usually above or left for form fields).
  • Placeholder — greyed example text inside a text field; it is not a substitute for a label.
  • Icon — a small graphic symbol. If an icon is not universally recognised, add a text label.
  • Grouping & hierarchy — visual grouping (boxes, spacing, headings) shows which elements belong together. Hierarchy (size, weight, color) shows what is most important.
  • Affordance vs. Signifier — a signifier is the explicit cue (visual affordance) that indicates where the action can take place (e.g., a raised panel, a shadow). Use signifiers consistently.
  • Modal vs. Non-modal — a modal UI element (for example, a modal dialog) blocks interaction with the rest of the interface until dismissed. Non-modal elements (for example, a tooltip) do not block.
  • Accessibility — design elements so they work for people using screen readers, keyboard-only navigation and other assistive tech. Provide keyboard focus order, visible focus outline, ARIA labels where needed and sufficient contrast for text. Meet WCAG 2.1 AA contrast ratios: body text at least 4.5:1 (3:1 for large text ≥18 pt or 14 pt bold), and interactive component boundaries/focus indicators at least 3:1 against adjacent colors.

Assumptions commonly stated in exam answers:

  • Elements are presented on a 2-D visual surface (screen) and are seen at typical viewing distances for the device (phone ~40–50 cm from eyes; desktop ~60–80 cm). When physical size matters (touch targets), specify the measurement unit.
  • Users fall into categories of novice/intermediate/expert; design patterns can differ (novices need clearer labels and feedback; experts rely on shortcuts).

Design rules and exact statements often required in answers:

  • Place the label where reading order is natural: left of field for short forms (Western left-to-right), above field for mobile forms to avoid long horizontal scanning.
  • Required fields must be clearly marked. Use consistent text or symbol (e.g., an asterisk) and provide inline validation messages close to the control. For web forms, also set the required attribute (and aria-required="true" if needed) so assistive technologies announce the requirement.
  • Make interactive targets large enough to be chosen reliably by the intended input method (mouse pointer vs. finger touch). Provide adequate spacing between targets to avoid accidental activation. For touch, aim for a minimum target size of about 9–10 mm with at least ~2 mm spacing between targets (platform guidance: iOS 44 pt, Android Material 48 dp); for mouse, 24 px or larger is generally usable.
  • Use visual state changes for focus and activation. For keyboard navigation, a visible focus indicator must exist for every interactive element.

What to draw for an exam diagram (describe exactly):

  • For a form layout question: draw a rectangle representing a device screen. Inside, draw three stacked labeled fields (Label above field). Show one field with a red border and an error message below it. Show a primary button (solid fill) and a secondary button (outline) side-by-side at the bottom. Label spacing values as “16 px” or as a physical size if asked.
  • For a button target and distance diagram: draw a horizontal line with two dots: Start (finger) and Button (target). Label the straight-line distance D. Draw the button width W. Mark index of difficulty calculation using D and W.

Refer to related topics by name rather than re-teaching them: when you need precise performance formulas (Fitts's law, Hick's law), see the course topic Fitts's law and Hick's law for derivations and constants.

Formulas

ID = log2(D / W + 1) — where ID is the Index of Difficulty (bits), D is the distance to target (m), W is the target width measured along the approach axis (m). Use when estimating pointing difficulty; applies to pointing tasks and to compare relative difficulty between targets.

MT ∝ ID — Movement Time (s) is proportional to Index of Difficulty. The full linear Fitts equation (MT = a + b·ID) and the constants a, b are covered in the Fitts's law topic; use that topic when a numerical MT is required.

T = a + b·log2(n + 1) — Hick's law (time T in s increases with log of choices n); constants a,b depend on context. See the Hick's law topic for derivation and when to apply. Note: some texts use log2(n) (equal-probability case) without the +1; follow your course convention and keep it consistent.

Notes on symbols and units: D and W must be in SI units (metres). ID is dimensionless (bits). MT and T are in seconds. These formulas apply to human pointing/decision tasks and are empirical (they hold under the experimental conditions usually stated in Fitts/Hick studies).

Worked examples

Example 1 — Form layout and validation (design + explanation) Problem: Design a 3-field login form for mobile: Email, Password, Remember me (checkbox), and a Login button. Show labels, placeholders, error handling and accessibility notes. Answer (step-by-step):

  1. For each input field, provide a clear label above the field: “Email” then a text field; “Password” then a password field. (Labels above are faster to scan vertically on mobile.) On the web, associate labels programmatically using a <label for> and matching input id; use input types and autocomplete (type='email', autocomplete='username'; type='password', autocomplete='current-password') to aid entry.
  2. Use placeholders only for example content, not labels. Example: placeholder for Email: “name@example.com”. Do not remove the label when input is filled.
  3. Place the checkbox “Remember me” below the fields, left-aligned with the left edge of fields.
  4. Place the primary action button “Login” below everything, full width for easy tapping on mobile. Use a contrasting color and show a disabled state when required fields are empty.
  5. Validation: if the email is invalid, show an inline error message immediately below the Email field in red and add aria-invalid="true" and aria-describedby referencing the error text for screen readers.
  6. Keyboard focus: ensure focus order is Email → Password → Remember me → Login. Provide a visible focus ring for each control.
  7. Spacing: at least 8–16 px vertical gap between controls (or the equivalent physical spacing). Use at least a 9–10 mm (≈44–48 px/pt/dp) touch target for the button and other tappable controls. Final: a clean vertical layout with accessible attributes and inline validation ensures clarity and usability.

Example 2 — Comparing two button targets using Index of Difficulty Problem: Two buttons on a desktop: Button A has width W_A = 20 mm, Button B has width W_B = 40 mm. The distance from pointer start to center of each button is D = 150 mm. Compute ID for each and state which will be faster to point at. Solution (numbered steps):

  1. Convert to metres for SI: D = 150 mm = 0.150 m; W_A = 20 mm = 0.020 m; W_B = 40 mm = 0.040 m.
  2. Use ID = log2(D / W + 1).
  3. For Button A: ID_A = log2(0.150 / 0.020 + 1) = log2(7.5 + 1) = log2(8.5). Calculate: log2(8.5) ≈ log10(8.5)/log10(2) ≈ 0.929/0.301 ≈ 3.09 bits.
  4. For Button B: ID_B = log2(0.150 / 0.040 + 1) = log2(3.75 + 1) = log2(4.75). Calculate: log2(4.75) ≈ log10(4.75)/log10(2) ≈ 0.677/0.301 ≈ 2.25 bits.
  5. Conclusion: Button B has lower Index of Difficulty (2.25 bits vs 3.09 bits) and so should be faster to point at. Movement time MT will be proportionally lower for Button B (MT ∝ ID). Bold final: Button B (40 mm wide) will be faster to target than Button A (20 mm wide).

Common mistakes

  • Relying solely on colour to communicate state (fails for colour-blind users and some printouts).
  • No visible keyboard focus indicator — keyboard users and accessibility tools fail.
  • Icons without labels for uncommon actions — users may not recognise meaning.
  • Overuse of modal dialogs for routine confirmations — interrupts task flow.
  • Putting controls too close together or inconsistent alignment — increases cognitive load.

For your exam

Kinds of questions you will see:

  • Definitions (define UI element, affordance, signifier, state, control).
  • Short notes (explain label placement, accessibility for UI elements, modal vs non-modal, grouping and hierarchy).
  • Derivations / explain laws (you may be asked to apply the Fitts's law formula to compare targets — see the Fitts's law topic for a derivation).
  • Numericals (compute Index of Difficulty given D and W; compare two designs; convert pixel guidelines to physical sizes when device DPI is given).
  • Diagrams (draw a form layout showing labels, spacing, a control in error state and show keyboard focus order). What a full-marks answer includes:
  • Clear definitions of terms used (bold in your answer or underlined in exam notes), assumptions stated (device/viewing distance or DPI if physical sizes are required), correct application of formulas with units, neat labelled diagrams, and short accessibility considerations.

Quick check

  1. What is a perceived affordance?
  2. Where should a label be placed for a short horizontal form on desktop?
  3. Using ID = log2(D / W + 1), if D = 0.1 m and W = 0.02 m, what is ID (to 2 decimal places)?

Answers: 1) The visual cue that shows how to use an element (how it can be acted on). 2) Left of the field (aligned horizontally) for short forms in left-to-right languages. 3) ID = log2(0.1 / 0.02 + 1) = log2(5 + 1) = log2(6) ≈ 2.58.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?