Skip to content

Button component without margin overhangs by 2px #5357

@andysellick

Description

@andysellick

Description of the issue

The button component uses a 2px box shadow to provide a visual bottom border. This is used primarily instead of an actual bottom border because the other borders are already defined and this would cause a bevelling issue between the bottom and left/right borders. This means that the button component 'overhangs' by 2px at the bottom.

By default the button component has a margin bottom of 32px, which accounts for this 2px and then adds spacing in line with the spacing scale. However on GOV.UK we use the button component without bottom margin in our search filters, where it is supposed to line up with the bottom of a wrapping element. Due to this 2px of box shadow it doesn't, and we have to insert 2px of padding somewhere to account for this.

This is a very small thing, but if there were a way of preserving the look of the button while allowing it to not have this 2px of overhanging box shadow it would make integrating the button component into edge case scenarios like this a little easier.

Steps to reproduce the issue

Normal button appearance:

Normal button appearance with margin beneath

Button with zero margin applied to the bottom (note 2px overlap with containing element, highlighted):

Button inside a highlighted form element showing 2px overlap with container when margin removed

Use of button in GOV.UK search (mobile view) at bottom of containing element, note slight overlap/misalign with grey left border of container:

GOV.UK search page on mobile showing button overlapping bottom of containing element by 2px

Environment (where applicable)

  • Operating system: N/A
  • Browser: N/A
  • Browser version: N/A
  • GOV.UK Frontend Version: current (v5.6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    button🐛 bugSomething isn't working the way it should (including incorrect wording in documentation)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions