Sunday, April 28, 2024
HomeTechnologySoftwareCSS ::file-selector-button

CSS ::file-selector-button

Date:

Related stories

NEVS Emily GT designed by ex-Saab engineers might be built in Italy

The Saab story continues under the NEVS banner...

30-Minute Bang Bang Shrimp Tacos

This website may contain affiliate links and advertising...

Another Crab’s Treasure Idle Animation Secretly Griefs Players

Another Crab’s Treasure is finally out, and if...
spot_imgspot_img


We all love beautifully styled form controls but, due to the differences between operating system displays, styling them can be painful. Due to that pain, we’ve created scores of libraries to mock these controls. Unfortunately that sometimes comes at the cost of accessibility, performance, etc.

One control that has traditionally been tough to style is the input[type=file] element. Said input variation visually contains a button and text, all being clickable. Bit of a Frankenstein’s monster if you ask me. Can we style the button part though? We can!

To style the button button portion of input[type=file], you can use ::file-selector-button:

input[type=file]::file-selector-button 
  border: 1px solid green;
  background: lightgreen;

Styling this input variant wasn’t possible when it was first introduced. WebKit first started allowing styling complex form controls, and we can’t thank them enough!

The post CSS ::file-selector-button appeared first on David Walsh Blog.



Source link

Latest stories

spot_img