Style file upload fields

Created on 5 March 2020, about 5 years ago
Updated 21 June 2024, 10 months ago

Problem/Motivation

Follow-up issue split off from 🐛 Style long text fields and text format dropdowns Fixed

Drupal's file upload element doesn't match Bootstrap 4 button styles when using a radix theme or subtheme.

<!-- break -->

Proposed resolution

Standard web browser file upload buttons are actually impossible to theme. Even default bootstrap 4 doesn't follow its own design patterns). Therefore, there is an opportunity to provide a javascript-driven Bootstrap-4 compatible solution like one of these:

  1. A single button solution

    <label class="file-upload btn btn-primary">
      Choose file ... <input type="file" />
    </label>
    <script>
        $(document).ready(function() {
            $('.file-upload').file_upload();
        });
    </script>
    
  2. Or an inline input group solution

    <div class="input-group">
      <div class="input-group-prepend">
        <span class="input-group-text" id="edit-profile-image-label">Upload</span>
      </div>
      <div class="custom-file">
        <input type="file" class="custom-file-input" id="edit-profile-image"
          aria-describedby="edit-profile-image-label">
        <label class="custom-file-label" for="inputGroupFile01">Choose file</label>
      </div>
    </div>
    
📌 Task
Status

Closed: outdated

Version

4.0

Component

User interface

Created by

🇪🇨Ecuador jwilson3

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024