UI Design · Lesson 07 / 12
Buttons & forms
Designing the controls people act with: button hierarchy, labels, sizes and states; form layout, labels, input types, selection controls, validation and error messages that help people succeed.
5 min read · 5 quiz questions
Buttons: the anatomy
A button has a container, a label, and optionally a leading or trailing icon. Its job is to tell people clearly what will happen when they press it, and to show that it's pressable.
- Height follows your spacing scale: commonly 32px (small), 40px (medium), 48px (large).
- Horizontal padding is usually 12–24px depending on size.
- Touch target should be at least 44×44pt (Apple) or 48×48dp (Material), even if the visible button is smaller.
- Corner radius is part of your brand language — keep it consistent across all components.
Button hierarchy
| Type | Appearance | When to use |
|---|---|---|
| Primary | Filled with the accent colour | The single most important action in a view |
| Secondary | Outlined or tonal (light fill) | Important alternatives: Save draft, Back |
| Tertiary / text | Text only | Low-emphasis actions: Cancel, Learn more |
| Destructive | Red fill or red text | Deleting, removing, irreversible actions |
| Icon button | Icon only, with an accessible label | Compact actions: close, more, favourite |
Common mistake: Two primary buttons side by side, e.g. a filled "Cancel" and a filled "Save". Users can't tell which is the main action — and some will press the wrong one.
Writing button labels
Do
- Start with a verb that describes the result: "Send invoice", "Create account".
- Be specific: "Delete 3 files" rather than "OK".
- Keep it short — usually 1–3 words.
- Match the label to the heading or question: "Delete project?" → "Delete project".
Don't
- Use vague labels: "OK", "Submit", "Click here", "Yes".
- Use different words for the same action in different places.
- Write in all caps for long labels.
- Hide important consequences: "Continue" that actually charges a card.
Button states
| State | How to show it |
|---|---|
| Default | The resting style |
| Hover | Slightly darker or lighter fill; pointer cursor (desktop only) |
| Focus | A clearly visible focus ring (2px outline with offset) for keyboard users |
| Pressed / active | Darker fill, sometimes a slight scale-down |
| Disabled | Low contrast, no hover; explain why if possible |
| Loading | Spinner inside the button, label kept or replaced; prevent double clicks |
Live preview
Default
Hover
Focus
Pressed
Disabled
Loading
Disabled buttons are often confusing — people don't know why they can't continue. Consider keeping the button enabled and showing what's missing when it's pressed, or explain the requirement next to it.
Form layout
- Single column. Research by usability experts consistently finds single-column forms faster and less error-prone than multi-column ones. Exceptions: short related fields like City + Postal code.
- Group related fields with headings (Personal details, Delivery, Payment).
- Order fields logically — the way people think about the information.
- Ask only what you need. Every extra field lowers completion. Remove, make optional or ask later.
- Match field width to the expected input — a postal code field shouldn't be full width.
- Place the primary button aligned with the inputs, at the end of the form.
Labels, placeholders and help text
Labels
Every input needs a visible label, placed above the field (fastest to scan, works on mobile and with long translations). Labels must be connected in code (<label for>) so screen readers announce them.
Placeholders
Use placeholders only for examples of format ("name@example.com"), never as the label. Placeholder text disappears as soon as people type, is usually low-contrast, and is often mistaken for a pre-filled value.
Help text
Short hints below the field explain requirements up front: "At least 8 characters, including a number". Showing rules before people type prevents errors.
Required vs optional
If most fields are required, mark only the optional ones with "(optional)". If most are optional, mark the required ones. Explain the asterisk if you use it.
Choosing the right input
| Need | Control | Notes |
|---|---|---|
| Short text | Text input | Use the right type: email, tel, url, number — mobile keyboards adapt |
| Long text | Textarea | Show a character limit if there is one |
| One choice from 2–5 | Radio buttons | All options visible; one default if sensible |
| One choice from many | Select / dropdown or combobox | Add search when the list is long (countries) |
| Several choices | Checkboxes | Each independent; a single checkbox for consent |
| On/off that applies immediately | Toggle switch | Use a checkbox instead if a Save button is needed |
| A date | Date picker plus typing | Let people type known dates like a birthday |
| A number in a small range | Stepper or slider | Show the exact value |
<label for="email">Email</label>
<input id="email" type="email" autocomplete="email"
inputmode="email" placeholder="name@example.com" required>
<p id="email-hint">We'll send the receipt here.</p>Validation and error messages
- Validate at the right time — usually when the user leaves a field (on blur) or on submit. Don't show errors while they're still typing their first attempt.
- Show errors next to the field with an icon, colour and text — not colour alone.
- For long forms, also show a summary at the top that links to each error, and move focus there.
- Keep what the user typed. Never clear a form because of one error.
- Confirm success — show that the form was submitted and what happens next.
| Bad error | Good error |
|---|---|
| Invalid input | Enter an email address like name@example.com |
| Error: password | Password needs at least 8 characters — you have 6 |
| Field required | Enter your postal code so we can calculate delivery |
| 422 Unprocessable | This card has expired. Use a different card. |
A good error message answers three questions: What happened? Why? How do I fix it? — in plain, polite language, without blaming the user.
Key takeaways
- Buttons need a clear hierarchy: one primary action per view, with secondary and tertiary styles.
- Label buttons with specific verbs that describe the result.
- Design every state: hover, focus, pressed, disabled and loading.
- Forms work best in a single column with visible labels above fields and only necessary questions.
- Validate at the right moment and write errors that explain how to fix the problem.
Exercise
Redesign a sign-up form
- Find a sign-up or checkout form with at least 8 fields.
- Remove or postpone every field that isn't essential.
- Redesign it in one column with labels above, help text and correct input types.
- Design error states for three fields with helpful messages.
- Design the button in all six states.
Test yourself
Buttons & forms quiz
5 questions. Score 70% or more to complete the lesson.
