Skip to content

Styling file upload button #1232

@jcbsv

Description

@jcbsv

I suggest to revive issue #812 regarding styling of upload buttons.

The ::file-selector-button CSS selector now has wide (if not universal) adoption.

The following code (adopted from buttons-core.css and buttons.css) shows an example implementation:

input::file-selector-button {
    display: inline-block;
    line-height: normal;
    white-space: nowrap;
    vertical-align: middle;
    text-align: center;
    cursor: pointer;
    -webkit-user-drag: none;
    user-select: none;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 100%;
    padding: 0.5em 1em;
    color: rgba(0, 0, 0, 0.80);
    border: none rgba(0, 0, 0, 0);
    background-color: #E6E6E6;
    text-decoration: none;
    border-radius: 2px;
}

input::file-selector-button:hover,
input::file-selector-button:focus {
    background-image: linear-gradient(transparent, rgba(0,0,0, 0.05) 40%, rgba(0,0,0, 0.10));
}
input::file-selector-button:focus {
    outline: 0;
}
input::file-selector-button:active {
    box-shadow: 0 0 0 1px rgba(0,0,0, 0.15) inset, 0 0 6px rgba(0,0,0, 0.20) inset;
    border-color: #000;
}

The result in Safari (Swedish language):
Skärmavbild 2023-11-23 kl  07 52 07

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions