Faragiri
English

Choose a language 2

Learn Buttons Components

A Nantes room booking where a confirmation dialogue was dismissed in under two seconds, and a ten second undo recovered fourteen bookings.

7Sections
5Min read
4Depth

Recommended Before This

0 / 1

A button does something and a link goes somewhere. Almost every button problem starts by breaking that sentence: a link painted to look like a button, or a button that navigates, and from there the keyboard, the middle click, the browser history and the screen reader all behave wrongly for reasons nobody can trace.

Camille is building the button set for a community centre's room booking system in Nantes. Four emphases, six states, and one action on the screen that cannot be taken back.

The ladder, and the one at the top

Four emphases: primary, secondary, quiet and destructive. Primary is filled and is what the screen exists to do. Secondary is outlined and is the alternative a reasonable person might take. Quiet is text only, for things that are always available and rarely wanted.

One booking screen

How loud each rung is, and what each is for

Ordered by how much of the screen's attention each one takes, which is the only ordering a reader can perceive.

  1. 04Primaryfilled, one per region, and the thing the screen exists to doone only
  2. 03Destructive secondaryoutlined and in the danger hue, which is where cancel booking sits until the screen is about cancelling
  3. 02Secondaryoutlined, for the alternative a reasonable person might take instead of the primary
  4. 01Quiettext only, for actions that are always available and rarely wanted, such as a print linkquietest

Destructive is drawn here as a rung and is really a property crossed with the other three. What makes an action safe is an undo rather than a colour, and no position on this ladder provides one.

Modular Type Scale & CSS Flex/Grid Motion Lab

Test harmonic typography ratios and live Flexbox/Grid layouts with 1-click CSS export.

One primary per screen region, and a second is a competition. Two filled buttons side by side is not two important actions, it is a screen that has not decided, and the reader resolves it by picking the one on the right or the one they read last.

Destructive is not a fifth rung, it is a property crossed with the other three. Cancel booking is drawn as a secondary until the moment it is the point of the screen, and colour alone does not make a button destructive: a red button that does the same thing as a grey one, with the same confirmation and the same recovery, is a colour decision rather than a safety one.

The label and the target

The label is a verb and an object: save draft, not OK. Yes, OK, Continue and Submit are all words about the dialogue rather than about the world, and the reader is deciding about the world.

Label and hit area

Keep the visual box compact, but extend the tap target to 44 px

Padding or a pseudo-element bridges the gap between a tidy 32 px button and a finger tapping in a corridor.

vertical pixels

  1. Visual button heightDrawn size carrying a verb-and-object label like Save draft rather than OK32 px
  2. Touchable hit targetExtended with padding or a pseudo-element without shifting surrounding layout44 px

Verb-and-object labels describe what changes in the world, while the 44 px target stops missed taps on phones.

A 32 px button still needs a 44 px target, from padding. The visual size and the touchable size are two different things, and the gap between them is filled with padding or a pseudo-element that extends the hit area without moving anything. On a booking screen used on phones in a corridor, that difference is most of the missed taps.

Six states, and the one that gets missed

Six states, and loading is the one that gets missed. Default, hover, focus, active and disabled all exist in every design file. Loading exists in the code and usually nowhere else, invented by whoever implemented it, in whatever form was quickest.

Six states in flight

Delay the loading spinner until 200 ms so fast clicks stay crisp

Showing a spinner on an 80 ms reply looks like a glitch; waiting 200 ms hides flashes while still stopping double bookings.

milliseconds after press

show loading state
instant clickspinner visible
  1. Fast server reply80 msCompletes before the threshold so no distracting spinner flashes
  2. Loading threshold200 msShows loading state and blocks repeat presses that cause duplicate room bookings

All five visual states belong in the design file, and loading belongs there too so developers do not invent it ad hoc.

It matters because the loading state is what stops a double submission. A button that stays pressable while the request is in flight gets pressed again, and on this system that produced two bookings for one room.

Show the loading state only after 200 ms, or it flashes. A response that arrives in 80 ms with a spinner in front of it looks like a fault, and a delay before showing the indicator makes fast actions feel instant and slow ones feel handled.

Undo instead of asking

An undo beats a confirmation, and ten seconds is enough. A confirmation dialogue interrupts everybody to protect the few, and after the third one it is dismissed by reflex, which means it protects nobody while costing everybody a step.

Protecting mistakes

A ten-second undo bar beats a confirmation dialogue

Pop-up confirmations train people to dismiss them by reflex; an undo bar lets the action happen and still reverses errors.

Confirmation dialogueInterrupts before acting
Ten-second undo barActs, then offers reversal
Routine experienceBlocks every user with an extra clickCompletes the action right away
After repeated useDismissed automatically without readingResult on screen draws immediate attention
Actual mistake recoveryNone once the dialogue is confirmedReversible for ten seconds from the footer bar

Undo takes more engineering effort than a modal, yet it is the only pattern of the two that genuinely recovers wrong clicks.

An undo does the opposite: the action happens, the person sees the result, and a bar at the foot of the screen offers to reverse it for ten seconds. It is more work to build and it is the only one of the two that actually recovers mistakes.

What to open

The HTML button element is the tool, part of the language and free, and it replaces a div with a click handler. What arrives free with a real button is the role, the keyboard behaviour on both Enter and Space, the form submission, the disabled semantics and the focus behaviour, all of which have to be rebuilt by hand otherwise and are usually rebuilt incompletely.

What to open

What a native HTML button and focus-visible give you free

Using standard browser primitives avoids half-rebuilding keyboard triggers, focus rings, and disabled semantics on a div.

Native button primitives

  1. YesBuilt-in button roleScreen readers recognise the control without custom ARIA hacksYes
  2. YesEnter and Space activationBoth keyboard keys work consistently out of the boxYes
  3. YesForm submission and disabled stateNative disabled semantics prevent accidental clicks and focusYes
  4. YesCSS focus-visible ring (since 2022)Shows rings for keyboard navigation while staying hidden on mouse clicksYes
  5. NoDiv with click handler and outline noneDrops keyboard users and leaves half the interaction model brokenNo

Both HTML button and CSS focus-visible are part of the web platform in every modern browser at zero cost.

CSS focus-visible is the other one, part of the language and in every current browser since 2022. It shows a focus ring for keyboard users and not for mouse clicks, which removes the reason people had been deleting focus rings for twenty years. Anybody still writing outline none is solving a problem the language solved.

Where it stalls: the states are inherited by guesswork

The six states get drawn for the primary button, carefully, in a review, with everybody looking. The other three emphases are then produced by somebody who applies the same logic in their head at half past four.

Where it stalls

Four emphases by six states, and where late-day guesswork creeps in

Teams review the primary button carefully, then invent secondary, quiet, and destructive states from memory at half past four.

specification rigour from 0 (missing) to 3 (reviewed in design file)

DefaultHoverFocusActiveDisabledLoading
Primary333331
Secondary212110
Quiet210110
Destructive211110

Filling out all twenty-four cells in one dull table prevents inconsistent hovers, missing quiet focus rings, and three mismatched disabled greys.

What comes out is a set where the primary's hover darkens by one step and the secondary's hover fills completely, where the quiet button has no focus state at all because text does not look like it needs one, and where disabled means grey in three different greys.

Nothing here is difficult. It is a table with four rows and six columns, and it never gets made, because making it is dull and drawing the primary button is the part that feels like designing.

What it looks like when it goes wrong

The centre's cancel action was a red button behind a confirmation dialogue. In a year it had been used about four hundred times, and the dialogue had been dismissed with the confirming button in a median of under two seconds, which is not reading. Replacing it with an immediate cancellation and a ten second undo recovered fourteen bookings in the first month, all of them people who had pressed the wrong row and seen it happen.

Nantes booking incident

Replacing a reflex-clicked dialogue with undo recovered fourteen bookings

Four hundred cancellations a year blew past the confirmation modal in under two seconds; an undo bar let people catch wrong-row clicks.

Red button plus modalDismissed in under two seconds by reflex
  1. 01Cancel the row immediatelyShowing the removed booking right away makes an accidental row click obvious
  2. 02Offer a ten-second undo windowGives people who tapped the wrong row a single-click way back
Instant cancel plus undoFourteen bookings saved in month one

Safety comes from reversibility after a mistake, not from putting one more confirmation box in front of a red button.

The field this button sits beside has an anatomy of its own, which is fields, selects and getting data in. Everything a real button element gives away for free is described from the other side in focus order, and never trapping it. And the choice between a dialogue and an undo is a question about interruption, which is when to interrupt, and when not to. How the four emphases and six states become one component rather than twenty four drawings is one level up, in the parts an interface is assembled from.

Alongside this

Above this