Button Spacing Calculator

Work out the gap between a row of buttons from the container width, the number of buttons and the width of each button. It also shows the space left for each spacing style.

1 Fill in the boxes

2 Your answer

Your answer shows here as you type.

How to use the Button Spacing Calculator

  1. Enter the width of the container that holds the buttons.
  2. Enter how many buttons sit in the row and the width of each one.
  3. Read the gap for space-between, space-evenly or space-around, and use the matching CSS justify-content value.

Frequently asked questions

How do you calculate the gap between buttons?

Subtract the total button width from the container width, then divide the free space by the number of gaps. With n buttons in a row there are n minus 1 gaps, so the gap is (container width minus n times button width) divided by (n minus 1).

What is the difference between space-between and space-evenly?

Space-between places all the free space between the buttons, with none at the edges. Space-evenly places equal space between the buttons and at both ends of the row.

What is a typical gap between buttons?

Many interfaces use 8 to 16 px between buttons on mobile and 16 to 24 px on larger screens. The right value depends on the design and the touch target size.

Wrote something with AI? Slop Monkey rewrites it so it sounds like you, and keeps your facts.