Made with 🧠 and πŸ«€ by Youssef Bouksim

Back to library
πŸ“

Law of Proximity

Objects that are close together are perceived as related. Objects that are far apart are perceived as separate. Spatial distance is a meaning signal β€” and it fires before any conscious reading begins.

5 min readUX Β· Layout Β· Forms

The Law of Proximity is one of the original Gestalt principles, and the most immediate. It operates before colour, before labels, before any deliberate reading β€” in under 100 milliseconds. When two elements are close together, the brain automatically groups them. When they are far apart, the brain automatically separates them. This is not an inference users make; it is a perceptual reflex that happens whether they intend it or not.

The practical consequence for design is precise: every gap in your layout is communicating a relationship β€” or its absence. A label that sits equally far from the field above it and the field below it is communicating ambiguity. A button that is far from the content it acts on is perceived as less directly connected to it. An error message at the top of a form is perceived as belonging to the form as a whole, not to the specific field that caused it.

Proximity is also the cheapest design tool available. It costs nothing β€” no new colour, no new component, no visual treatment. Only the intentional use of space. The difference between a form that confuses users and one that communicates its structure instantly is often a matter of 15 pixels redistributed in the right direction.

✦ Key takeaways
βœ“
A label must be closer to its field than to any other element. When label-to-input spacing equals input-to-next-label spacing, the label genuinely floats between two fields perceptually. Users must read every label to determine which field it belongs to. Asymmetric spacing β€” small gap below the label, large gap above it β€” resolves this instantly.
βœ“
Error messages belong next to the field that caused them, not above the form. An error summary at the top of a form is spatially equidistant from every field. Users must read both the error and every label to find the match. An inline error immediately below the relevant field is unambiguous β€” proximity identifies the cause before reading.
βœ“
Uniform spacing communicates nothing. A layout where every gap is 16px β€” between label and input, between input and label, between sections β€” provides no spatial hierarchy. Users cannot infer structure from spacing because all spacing is identical. Intentional variation β€” tight for related elements, generous for unrelated ones β€” is what makes proximity work.
β€œElements near each other tend to be seen as part of a group, while those farther apart are seen as separate β€” regardless of any other visual property.”
β€” Max Wertheimer, Gestalt Psychology, 1923

The most common proximity error in UI β€” form labels

Ask a designer to point to a proximity error in a live product and they will usually struggle. Ask them to look at a form where every gap β€” between label and input, between input and next label β€” is the same value, and they will eventually see that each label floats ambiguously between two fields. But they will have to look for it. Users don't look for it. They just experience the confusion it produces without knowing why.

The fix is asymmetric spacing, and it is one of the most impactful micro-decisions in form design. A label that sits 5px from its input and 28px from the previous input is unambiguously grouped with its field. Users perceive each label-input pair as a single unit before reading anything. The form's structure is visible from spacing alone.

Before β€” labels float between fields
yourapp.com/signup
A
Acme
Create your account
Get started for free β€” no credit card required.
Youssef Bouksim
you@example.com
Create a password
Confirm your password
Create account
Every gap is 20px β€” label-to-input and input-to-next-label are identical. Each label sits equidistant between two fields. Users must read every label to know which field it belongs to.
After β€” each label hugs its field
yourapp.com/signup
A
Acme
Create your account
Get started for free β€” no credit card required.
Youssef Bouksim
you@example.com
Create a password
Must be at least 8 characters
Confirm your password
Create account
Labels sit 5px from their input, 28px from the previous field. Each label-input pair is a visually distinct unit. The hint on Password hugs its field from below β€” same principle.

Look at both forms and notice where your eye groups the label. In the bad form, β€œEmail address” sits exactly midway between the Name input above and the Email input below β€” perceptual ambiguity. In the good form, the label is unambiguously attached to the field below it. The information is identical. Only the spacing changed.


Error messages β€” at the top of the form vs next to the field

Error summary boxes at the top of a form are a direct proximity failure. β€œEmail address is invalid” placed above four form fields is spatially equidistant from all of them. Users read the error, then must scan every field to find the one it refers to. This is a two-step process where proximity could make it zero steps.

An inline error β€” placed 5px below the field it refers to, in the same red that the field border has turned β€” requires no scanning. Proximity identifies the cause before the user reads anything. The field and its error are one visual unit, exactly as the label and field are one visual unit in the good form above.

Before β€” errors equidistant from every field
yourapp.com/signup
A
Acme
Create your account
Get started for free β€” no credit card required.
Please fix the following errors:
Email address is not valid
Password must be at least 8 characters
Passwords do not match
Youssef Bouksim
youssef@
β€’β€’β€’
β€’β€’β€’β€’
Create account
Three errors listed at the top, four fields below. Users must read each error then scan every field to find the match. The error summary is equally far from every field.
After β€” each error hugs its field
yourapp.com/signup
A
Acme
Create your account
Get started for free β€” no credit card required.
Youssef Bouksim
youssef@
Enter a complete email address (e.g. you@example.com)
β€’β€’β€’
Must be at least 8 characters
β€’β€’β€’β€’
Passwords do not match
Create account
Each error appears 5px below its field. No scanning required. The red field border and the red error text form one visual unit. Fix the field, fix the error.

Both demos apply the same principle: small gap signals β€œthis belongs to what's above it.” The hint on the password field in Demo 1 and the error messages in Demo 2 use identical proximity logic β€” 5px below their field, belonging unambiguously to it. Users who have learned that proximity means belonging read both correctly without instruction.


Applying this to your work

Proximity problems in real products almost always stem from uniform spacing β€” applying the same gap value to every element regardless of the relationships being communicated. The fix is not a design system change or a new component. It is a spacing audit: for every label, hint, error, action, or caption in your product, ask β€” is this element closer to the thing it belongs to than to anything else? If the answer is no, move it.

The rule is simple enough to apply anywhere: tight spacing (4–6px) within a group, generous spacing (20–32px) between groups. Labels hug their inputs. Error messages hug their fields. Hints hug their inputs. Captions hug their images. Section headers have more space above them than below. The entire spatial hierarchy of a form, a card, or a settings page can be communicated through spacing alone β€” before a word is read.

βœ“ Apply it like this
β†’Use asymmetric form spacing β€” 5px between a label and its input, 24–28px between an input and the next label. Labels hug their field; fields are separated from each other.
β†’Place error messages inline, immediately below the field they refer to β€” not in a summary at the top of the form. Proximity identifies the cause before the user reads anything.
β†’Place hints, character counters, and helper text 4–5px below their input β€” not 16px. They belong to the field; the spacing should say so.
β†’Use spacing variation deliberately β€” tight within groups, generous between them. Uniform spacing communicates nothing about structure.
βœ— Common mistakes
β†’Using the same gap between label and input as between input and next label β€” labels float ambiguously between two fields and users cannot infer structure from spacing.
β†’Collecting all form errors into a summary box at the top β€” spatial distance from the fields makes each error equally ambiguous about which field it refers to.
β†’Placing helper text 16px below an input β€” at that distance it reads as a caption for the next element rather than help for the current one.
β†’Treating spacing as purely aesthetic β€” every gap is a relationship signal, whether or not it was intended to be.

Wertheimer, M. (1923). Laws of organization in perceptual forms. Psychologische Forschung, 4, 301–350. Β· KΓΆhler, W. (1929). Gestalt psychology. Liveright. Β· Ware, C. (2004). Information visualization: Perception for design. Morgan Kaufmann.