How to change "Choose file" Text using Bootstrap? Last Updated : 13 May, 2024 Comments Improve Suggest changes Like Article Like Report In web development, forms may include the file upload functionality which allows user to select files from their device. The standard HTML <input> element with type="file" provides us with this feature. But the default text displayed on the file input button is "Choose File," which may or may not be appropriate for our website. Choose file color change using Bootstrap 5Approach:At first create a basic Html structure and link the Bootstrap 5 CDN links.Then add an <input> element with type="file" to create a file upload control.For the style of your web page you can use those bootstrap 5 class like "container" , "row" , "form-control", "visually-hidden" for creates a responsive fixed-width container, define row within the Bootstrap grid system, styling to form elements ,hides an element.After that you can use the javascript for dynamically update the text , color of the text for that you can use the javascript classList.add() and classList.remove() method.Example : Below is the code example of how to change "Choose file" text using Bootstrap 5 HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Custom File Input</title> <!-- Bootstrap CSS --> <link href= "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body class="bg-secondary"> <div class="container mt-5 bg-light p-4 rounded shadow w-50"> <h3 class="text-center mb-4 text-success"> Change "Choose file" text using Bootstrap 5 </h3> <div class="row justify-content-center"> <div class="col-md-6"> <form class="ml-3 mt-4"> <div class="mb-3"> <label for="name" class="form-label text-success"> Name </label> <input type="text" class="form-control" id="name" placeholder="Enter your name"> </div> <div class="mb-3"> <label for="email" class="form-label text-success"> Email address </label> <input type="email" class="form-control" id="email" placeholder="[email protected]"> </div> <div class="mb-3"> <label for="message" class="form-label text-success"> Message </label> <textarea class="form-control" id="message" rows="3" placeholder="Enter your message"></textarea> </div> <div class="input-group mb-3"> <label for="inputGroupFile01" class="input-group-text bg-secondary text-white"> Upload file: </label> <input type="file" class="form-control visually-hidden" id="inputGroupFile01" aria-describedby="inputGroupFileAddon01" onchange="updateFileName(this)"> <span class="form-control bg-light text-secondary" id="fileNameDisplay">Choose file</span> </div> <button type="submit" class="btn btn-primary btn-lg">Submit</button> </form> </div> </div> </div> <!-- Bootstrap Bundle with Popper --> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"> </script> <script> // Change the label text when a file is selected let file_Name_Display = document .getElementById("fileNameDisplay"); function updateFileName(input) { if (input.files.length > 0) { file_Name_Display .innerText = "You chose: " + input.files[0].name; file_Name_Display .classList.remove("bg-light"); file_Name_Display .classList .add("bg-primary", "text-white"); } else { file_Name_Display .innerText = "Choose file"; file_Name_Display .classList.remove("bg-primary", "text-white"); file_Name_Display .classList .add("bg-light", "text-secondary"); } } </script> </body> </html> Output: Choose file color change using Bootstrap 5 Comment More infoAdvertise with us Next Article How to change "Choose file" Text using Bootstrap? skaftafh Follow Improve Article Tags : Web Technologies Bootstrap Bootstrap-Questions Similar Reads How to change font style on element using Bootstrap 5? Bootstrap enables changing font styles by applying predefined classes like .fw-bold for bold, .fst-italic for italic, etc., directly to HTML elements. This ensures consistent and responsive typography across web applications without needing custom CSS. There are a few Bootstrap Built-in Classes for 2 min read How to Create Custom Input File with Bootstrap? This article will show you how to create a custom input file using the Bootstrap 5 library. Bootstrap 5 has various styling file input classes and functionalities that can enhance the visual appearance of custom file input. There are two different approaches along with their implementation. In both 3 min read How to create a form within dropdown menu using Bootstrap ? A Dropdown menu is used to allow the user to choose the content from the menu as per their requirement and it is used to save screen space and avoid the long scrolling of the web pages. In web design, we often come in a scenario where we need to create a form within the dropdown menu to get some use 3 min read How to use bootstrap-select for dropdown? Bootstrap Select is a form control that shows a collapsible list of different values that can be selected. This can be used for displaying forms or menus to the user.ApproachThere are only some style properties that can be applied to the <option> component. This is because this sort of compone 2 min read How to change Dropdown Icon on Bootstrap 5? Dropdowns are toggleable, contextual overlays for displaying lists of links and more. Theyâre made interactive with the included Bootstrap dropdown JavaScript plugin. Theyâre toggled by clicking, not hovering this is an intentional design decision. In this article, we will learn How to change the Dr 4 min read How to Design Full Width Dropdown Navbar using Bootstrap? A full-width dropdown navbar is a popular design element in modern web development, providing a responsive and user-friendly navigation experience. Using Bootstrap, a powerful front-end framework, simplifies the creation of such a navbar with its built-in classes and responsive grid system. This gui 4 min read Bootstrap 5 Form Controls File Input Bootstrap5 Form controls File input provides customized ways to take the input of the files, i.e., the file input can accept as default, or can accept multiple files at once, or can be disabled the file input. This can also be done for any file input size, which varies from small size to large. This 2 min read How to write a form in different line using Bootstrap ? Bootstrap is an open-source front-end framework for developing standard & decorative websites or web applications that are fast and user-friendly. Bootstrap includes templates based on HTML and CSS for tables, forms, buttons, etc. Bootstrap also uses JavaScript and helps us to create responsive 2 min read How to add image before optgroup label using Bootstrap ? What is optgroup label? It is an HTML tag that is used to group the options given in <select> tag. This combines the options in different groups having different labels. Syntax:Â HTML <optgroup label="text"> <option value="One">One</option> <option value="Two">Two</o 1 min read How to create a File Input using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be creating a File Input Area using jQuery Mobile. Approach: Add jQuery Mobile scripts needed for your project. <link rel=âstylesheetâ hr 1 min read Like