How can I add custom file input sizing to Bootstrap 4 by using the classes such as input-group-sm
, form-control-sm
etc..? I want to set this custom file input field as small. Does anyone have a solution?
form-control-sm
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="form-group">
<input class="form-control form-control-sm" value="Small input field">
</div>
input-group-sm
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">Go</span>
</div>
<input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3" value="Small input group">
</div>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="input-group input-group-sm">
<div class="custom-file">
<input type="file" class="custom-file-input form-control-sm">
<label class="custom-file-label">Choose file</label>
</div>
</div>
For a pixel precise solution, you would still need some extra CSS (in 2019). If you want a Bootstrap-only solution, add .col-form-label
class to the <label>
tag and use Bootstrap Version 4.3. There is still an extra 0.25 rem for the height, but you can use this snipped the same way as other .form-Control-sm
elements.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="form-group">
<div class="custom-file">
<input type="file" class="custom-file-input">
<label class="custom-file-label">Choose file</label>
</div>
</div>
<div class="form-group">
<div class="custom-file">
<input type="file" id="customFile" class="custom-file-input form-control-sm">
<label class="custom-file-label col-form-label-sm" for="custmFile">Choose file</label>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With