<link href="https://cdn.jsdelivr.net/npm/swapform@1.1.5/dist/css/swapform.min.css" rel="stylesheet" integrity="sha384-+3eUgs577+T8GDbqKfSmwySyIdO8sxGi8Q1sz8Z48aJ5lFOTpGfIgS2/qu4RHG9U" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/swapform@1.1.5/dist/js/swapform.min.js" integrity="sha384-4m+UKOEpqFlMgA38LbGczPXdIP6Z/p+QKqZm8BBtrO0KEEqgU1BqQeIbsxKe73kF" crossorigin="anonymous"></script>
<div class="sf-form">
<label class="sf-label">Enter username</label>
<input type="text" class="form-control">
</div>
<div class="sf-form">
<label class="sf-label" data-description="Who are you?">Enter username</label>
<input type="text" class="form-control">
</div>
<div class="sf-form">
<label class="sf-label" data-description="Who are you?" data-filled="Username set!">Enter username</label>
<input type="text" class="form-control">
</div>
<!-- Small -->
<div class="sf-form">
<label class="sf-label-sm">Enter username</label>
<input type="text" class="form-control form-control-sm">
</div>
<!-- Large -->
<div class="sf-form">
<label class="sf-label-lg">Enter username</label>
<input type="text" class="form-control form-control-lg">
</div>
<div class="sf-form">
<label class="sf-label">Top 5 TV shows</label>
<textarea class="form-control sf-textarea-fixed-sm"></textarea>
</div>
<div class="sf-form">
<label class="sf-label">Top 5 TV shows</label>
<textarea class="form-control sf-textarea-sm"></textarea>
</div>
Expanding heights | ||
---|---|---|
Class | Height | Description |
sf-textarea-sm | 160px | Expanding. Height starts out small and expands to a maximum of 160px |
sf-textarea-md | 320px | Expanding. Height starts out small and expands to a maximum of 320px |
sf-textarea-lg | 640px | Expanding. Height starts out small and expands to a maximum of 640px |
sf-textarea | ∞ | Expanding. Height starts out small and expands to infinity |
Fixed heights | ||
Class | Height | Description |
sf-textarea-fixed-sm | 160px | Starts with a height of 160px, does not auto expand |
sf-textarea-fixed-md | 320px | Starts with a height of 320px, does not auto expand |
sf-textarea-fixed-lg | 640px | Starts with a height of 640px, does not auto expand |
Class | Description |
---|---|
sf-label-sm | Useful when using form-control-sm on an <input> element |
sf-label | Useful when using the regular form-control on an <input> element |
sf-label-lg | Useful when using form-control-lg on an <input> element |
Attribute | Description |
---|---|
data-description | Executes when an <input> element is focused by the user |
data-filled | Executes when an <input> element is no longer in focus by the user and the element has a value |
npm install swapform
<!-- Swapform CSS -->
<link href="https://cdn.jsdelivr.net/npm/swapform@1.1.5/dist/css/swapform.min.css" rel="stylesheet" integrity="sha384-+3eUgs577+T8GDbqKfSmwySyIdO8sxGi8Q1sz8Z48aJ5lFOTpGfIgS2/qu4RHG9U" crossorigin="anonymous">
<!-- Swapform JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/swapform@1.1.5/dist/js/swapform.min.js" integrity="sha384-4m+UKOEpqFlMgA38LbGczPXdIP6Z/p+QKqZm8BBtrO0KEEqgU1BqQeIbsxKe73kF" crossorigin="anonymous"></script>
<!-- Swapform CSS -->
<link href="https://unpkg.com/swapform@1.1.5/dist/css/swapform.min.css" rel="stylesheet" integrity="sha384-+3eUgs577+T8GDbqKfSmwySyIdO8sxGi8Q1sz8Z48aJ5lFOTpGfIgS2/qu4RHG9U" crossorigin="anonymous">
<!-- Swapform JavaScript -->
<script src="https://unpkg.com/swapform@1.1.5/dist/js/swapform.min.js" integrity="sha384-4m+UKOEpqFlMgA38LbGczPXdIP6Z/p+QKqZm8BBtrO0KEEqgU1BqQeIbsxKe73kF" crossorigin="anonymous"></script>
git clone https://github.com/runthis/swapform.git