Always Show Arrows for Number Input

While I enjoy small details that make user interfaces more elegant, I also believe that less is more, especially when it comes to native behavior. One native behavior I dislike is that <input type=”number” /> elements only show the increment and decrement arrows when the input is focused. It’s a needless focus change — just […]

The post Always Show Arrows for Number Input appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh

While I enjoy small details that make user interfaces more elegant, I also believe that less is more, especially when it comes to native behavior. One native behavior I dislike is that <input type="number" /> elements only show the increment and decrement arrows when the input is focused. It’s a needless focus change — just show those controls all the time.

So how do we show those controls when the input isn’t focused? An easy bit of CSS:

/* ensures the increment/decrement arrows always display */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button {
  opacity: 1;
}

I appreciate that the browser’s native stylesheet doesn’t use hidden tricks or privileged code — it’s all just CSS that we can override.

I’m always suspect when it comes to hover effects, as I feel hiding UI elements decreases accessibility no matter what the reason is.

The post Always Show Arrows for Number Input appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh


Print Share Comment Cite Upload Translate Updates
APA

David Walsh | Sciencx (2021-06-21T13:52:09+00:00) Always Show Arrows for Number Input. Retrieved from https://www.scien.cx/2021/06/21/always-show-arrows-for-number-input/

MLA
" » Always Show Arrows for Number Input." David Walsh | Sciencx - Monday June 21, 2021, https://www.scien.cx/2021/06/21/always-show-arrows-for-number-input/
HARVARD
David Walsh | Sciencx Monday June 21, 2021 » Always Show Arrows for Number Input., viewed ,<https://www.scien.cx/2021/06/21/always-show-arrows-for-number-input/>
VANCOUVER
David Walsh | Sciencx - » Always Show Arrows for Number Input. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/21/always-show-arrows-for-number-input/
CHICAGO
" » Always Show Arrows for Number Input." David Walsh | Sciencx - Accessed . https://www.scien.cx/2021/06/21/always-show-arrows-for-number-input/
IEEE
" » Always Show Arrows for Number Input." David Walsh | Sciencx [Online]. Available: https://www.scien.cx/2021/06/21/always-show-arrows-for-number-input/. [Accessed: ]
rf:citation
» Always Show Arrows for Number Input | David Walsh | Sciencx | https://www.scien.cx/2021/06/21/always-show-arrows-for-number-input/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.