Button/Input Sizing and Alignment Questions #2226
-
Hi there! I'm new to Twilio and I have a couple of questions around how the buttons and inputs are built. We have noticed on buttons and inputs specifically that objects that have borders sit outside the bound of the constraint. So when we align buttons or inputs to other objects, it is ever so slightly off by 1px because it aligns from the bounds of the button/input and not the outer edge of the border. I've attached a few examples - hopefully they help my explanation :) We were just wondering if this is intentional or if we could fix this in Paste so the alignment and spacing can be a little more accurate. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey @jkiga ! You've stumbled upon one of the quirks of the system, and the restrictions of working within a consistent 4px spacing & sizing structure. Our buttons and inputs use shadows for their borders (rather than true borders), so that the full height of a button/input is still a multiple of 4. Shadows don't factor into the browser's size calculations for UI elements, but borders do (i.e., a 1px border would add 2px extra height/width to each element). Not sure if you're familiar or not with the CSS Box model, but that's what's happening here—I'm happy to share more if you're not familiar. Screenshot of our secondary button if you use inspect its size and border: However this does make the border visually appear a few extra pixels wider and taller than their true size, which you've pointed out. For form fields, we were ok with the trade-off of the "border" appearing a pixel off from the form text label and believed that customers would find it negligible. tl;dr Yep, it's intentional. This question's come up a few times in the past (but not in GitHub Discussions unfortunately), so I wanted to make sure our answer here is documented comprehensively. Sorry if it's more than you asked for :) But! I'm curious what you're trying to align in your last 2 screenshots. If you can share a Figma file, that'd be really helpful. |
Beta Was this translation helpful? Give feedback.
Hey @jkiga ! You've stumbled upon one of the quirks of the system, and the restrictions of working within a consistent 4px spacing & sizing structure.
Our buttons and inputs use shadows for their borders (rather than true borders), so that the full height of a button/input is still a multiple of 4. Shadows don't factor into the browser's size calculations for UI elements, but borders do (i.e., a 1px border would add 2px extra height/width to each element). Not sure if you're familiar or not with the CSS Box model, but that's what's happening here—I'm happy to share more if you're not familiar.
Screenshot of our secondary button if you use inspect its size and border:
However this does ma…