I wasted a lot of time searching a way to make my own xs size (smaller than the small) for input and input group, so here's the code!
Peter Butkovic upload the bug/request to the bootstrap github:
https://github.com/twbs/bootstrap/issues/15107
with the following response from theirs:
We won't be adding it to v3 and I don't think we'll have the xs buttons even in v4, but I'll keep it in mind for that if we opt to keep it around.
Still working for Bootstrap 5
Starting today, Bootstrap 3 will move to end of life, and will no longer receive critical security updates. Bootstrap 4 will move to Long Term Support after we release v4. 4 and will no longer receive new features from then on.
Bootstrap 3 used floats to handle the layout unlike flexbox in Bootstrap 4. The Flexible Box Layout makes it easier to design flexible responsive layout structure without using float or positioning. Although it has responsive features, with custom CSS the implementation has become complex with Bootstrap 4.
Mobile first With Bootstrap 3, we've rewritten the project to be mobile friendly from the start. Instead of adding on optional mobile styles, they're baked right into the core. In fact, Bootstrap is mobile first.
Bootstrap is the latest version of Bootstrap and should be used but it mainly depends upon the code you are writing. If you are using JQuery instead of JS, then use Bootstrap 4 but if you are using JS then Bootstrap 5 should be preferred as Bootstrap 5 does not support JQuery.
For inputs smallers:
.input-xs {
height: 22px;
padding: 2px 5px;
font-size: 12px;
line-height: 1.5; /* If Placeholder of the input is moved up, rem/modify this. */
border-radius: 3px;
}
Sample usage in input-group:
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-xs btn-success">
<i class="glyphicon glyphicon-plus"></i>
</button>
</span>
<input type="text" class="form-control input-xs" />
<span class="input-group-btn">
<button class="btn btn-xs btn-danger">
<i class="glyphicon glyphicon-minus"></i>
</button>
</span>
</div>
Alternatively you can add class to the input-group like this one:
.input-group-xs>.form-control,
.input-group-xs>.input-group-addon,
.input-group-xs>.input-group-btn>.btn {
height: 22px;
padding: 1px 5px;
font-size: 12px;
line-height: 1.5;
}
and use:
<div class="input-group input-group-xs">
<span class="input-group-btn">
<button class="btn btn-success">
<i class="glyphicon glyphicon-plus"></i>
</button>
</span>
<input type="text" class="form-control" />
<span class="input-group-btn">
<button class="btn btn-danger">
<i class="glyphicon glyphicon-minus"></i>
</button>
</span>
</div>
.input-xs {
height: 22px!important;
padding: 2px 5px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
.input-group-xs>.form-control,
.input-group-xs>.input-group-addon,
.input-group-xs>.input-group-btn>.btn {
height: 22px;
padding: 1px 5px;
font-size: 12px;
line-height: 1.5;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-xs btn-success">
<i class="glyphicon glyphicon-plus"></i>
</button>
</span>
<input type="text" class="form-control input-xs" />
<span class="input-group-btn">
<button class="btn btn-xs btn-danger">
<i class="glyphicon glyphicon-minus"></i>
</button>
</span>
</div>
<br/>
<div class="input-group input-group-xs">
<span class="input-group-btn">
<button class="btn btn-success">
<i class="glyphicon glyphicon-plus"></i>
</button>
</span>
<input type="text" class="form-control" />
<span class="input-group-btn">
<button class="btn btn-danger">
<i class="glyphicon glyphicon-minus"></i>
</button>
</span>
</div>
If you are using bootstrap-sass
, then you can leverage input-size
mixin:
$input-height-xs: 27px; // adjust it according to your theme.
@include input-size('.input-xs', $input-height-xs, $padding-xs-vertical, $padding-xs-horizontal, $font-size-small, $line-height-small, $input-border-radius-small);
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