advanced forms
Tailwind CSS Toggle Count
The Toggle Count Component simplifies switching between different values, aiding comparison and decision-making on pricing pages.
Class Name | Type | Description |
---|---|---|
switch | Component | Component class for switch. |
Basic example of toggle count with radio input.
Free
0
All the basics for the business that are just getting started!
Essential
15
All the essentials for the business that need some added support!
Standard
60
All the standards for the businesses that need more growth.
Pro
100
All the advanced features with pro support & customizations!
<div class="mb-3 flex justify-center">
<div id="toggle-count" class="border-base-content/20 flex gap-0.5 rounded-btn border p-0.5">
<label for="toggle-count-monthly" class="btn btn-sm btn-text has-[:checked]:btn-active">
<span>Monthly</span>
<input id="toggle-count-monthly" name="toggle-count" type="radio" class="hidden" checked="" />
</label>
<label for="toggle-count-annual" class="btn btn-sm btn-text has-[:checked]:btn-active">
<span>Annually</span>
<input id="toggle-count-annual" name="toggle-count" type="radio" class="hidden" />
</label>
</div>
</div>
<div class="border-base-content/20 grid grid-cols-1 items-center rounded-xl border sm:grid-cols-2 md:grid-cols-4">
<div class="flex flex-col items-center justify-center gap-2 p-4">
<p class="mb-1 font-medium">Free</p>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count",
"min": 0,
"max": 0
}'
class="text-3xl sm:text-5xl">
0
</p>
</div>
<p class="text-sm text-center">All the basics for the business that are just getting started!</p>
</div>
<div class="flex flex-col items-center justify-center gap-2 p-4">
<p class="mb-1 font-medium">Essential</p>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count",
"min": 15,
"max": 159
}'
class="text-3xl sm:text-5xl">
15
</p>
</div>
<p class="text-sm text-center">All the essentials for the business that need some added support!</p>
</div>
<div class="flex flex-col items-center justify-center gap-2 p-4">
<div class="flex justify-between">
<p class="mb-1 font-medium">Standard</p>
</div>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count",
"min": 60,
"max": 699
}'
class="text-3xl sm:text-5xl">
60
</p>
</div>
<p class="text-sm text-center">All the standards for the businesses that need more growth.</p>
</div>
<div class="flex flex-col items-center justify-center gap-2 p-4">
<p class="mb-1 font-medium">Pro</p>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count",
"min": 100,
"max": 999
}'
class="text-3xl sm:text-5xl">
100
</p>
</div>
<p class="text-sm text-center">All the advanced features with pro support & customizations!</p>
</div>
</div>
Basic example of toggle count with switch(checkbox) input.
Free
0
All the basics for the business that are just getting started!
Essential
15
All the essentials for the business that need some added support!
Standard
60
All the standards for the businesses that need more growth.
Pro
100
All the advanced features with pro support & customizations!
<div class="mb-4 flex justify-center">
<div class="flex items-center">
<label for="toggle-count-switch" class="inline-block p-2">
<span class="text-sm cursor-pointer">Monthly</span>
</label>
<input id="toggle-count-switch" name="toggle-count-switch" type="checkbox" class="switch" />
<label for="toggle-count-switch" class="inline-block p-2">
<span class="text-sm cursor-pointer">Annually</span>
</label>
</div>
</div>
<div class="border-base-content/20 grid grid-cols-1 items-center rounded-xl border sm:grid-cols-2 md:grid-cols-4">
<div class="flex flex-col items-center justify-center gap-2 p-4">
<p class="mb-1 font-medium">Free</p>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count-switch",
"min": 0,
"max": 0
}'
class="text-3xl sm:text-5xl">
0
</p>
</div>
<p class="text-sm text-center">All the basics for the business that are just getting started!</p>
</div>
<div class="flex flex-col items-center justify-center gap-2 p-4">
<p class="mb-1 font-medium">Essential</p>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count-switch",
"min": 15,
"max": 159
}'
class="text-3xl sm:text-5xl">
15
</p>
</div>
<p class="text-sm text-center">All the essentials for the business that need some added support!</p>
</div>
<div class="flex flex-col items-center justify-center gap-2 p-4">
<div class="flex justify-between">
<p class="mb-1 font-medium">Standard</p>
</div>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count-switch",
"min": 60,
"max": 699
}'
class="text-3xl sm:text-5xl">
60
</p>
</div>
<p class="text-sm text-center">All the standards for the businesses that need more growth.</p>
</div>
<div class="flex flex-col items-center justify-center gap-2 p-4">
<p class="mb-1 font-medium">Pro</p>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count-switch",
"min": 100,
"max": 999
}'
class="text-3xl sm:text-5xl">
100
</p>
</div>
<p class="text-sm text-center">All the advanced features with pro support & customizations!</p>
</div>
</div>
Basic example demonstrates use of toggle count in pricing cards.
A simple start for everyone
3
- 100 responses a month
- Unlimited forms & surveys
- Unlimited fields
- Basic form creation tools
- Up to 2 subdomains
For small to medium businesses
15
- Unlimited responses
- Unlimited forms & surveys
- Instagram profile page
- Google Docs integration
- Custom Landing page
Solution for big organizations
79
- PayPal payments
- Logic Jumps
- File upload with 5GB storage
- Custom domain support
- Stripe integration
<div class="mb-3 flex justify-center">
<div id="toggle-price-count" class="border-base-content/20 flex gap-0.5 rounded-btn border p-0.5">
<label for="toggle-price-count-monthly" class="btn btn-sm btn-text has-[:checked]:btn-active">
<span>Monthly</span>
<input id="toggle-price-count-monthly" name="toggle-price-count" type="radio" class="hidden" checked="" />
</label>
<label for="toggle-price-count-annual" class="btn btn-sm btn-text has-[:checked]:btn-active">
<span>Annually</span>
<input id="toggle-price-count-annual" name="toggle-price-count" type="radio" class="hidden" />
</label>
</div>
</div>
<div class="grid grid-cols-1 items-center gap-2 sm:grid-cols-2 md:grid-cols-3">
<div class="card border-base-content/20 border shadow-none">
<div class="card-body gap-3 text-center">
<div>
<span class="text-base-content text-xl font-medium ">Basic</span>
<p class="text-sm truncate">A simple start for everyone</p>
</div>
<div class="text-primary flex justify-center gap-x-1">
<span class="text-base-content/80 text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-price-count",
"min": 3,
"max": 29
}'
class="text-5xl font-semibold">
3
</p>
</div>
<ul class="text-sm space-y-3">
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">100 responses a month</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Unlimited forms & surveys</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Unlimited fields</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Basic form creation tools</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Up to 2 subdomains</span>
</li>
</ul>
<button class="btn btn-outline btn-sm btn-primary mt-4">UPGRADE</button>
</div>
</div>
<div class="card border-primary border shadow-none">
<div class="relative">
<span class="badge badge-soft badge-sm badge-primary absolute end-2 top-2">Popular</span>
</div>
<div class="card-body gap-3 text-center">
<div>
<span class="text-base-content text-xl font-medium ">Standard</span>
<p class="text-sm">For small to medium businesses</p>
</div>
<div class="text-primary flex justify-center gap-x-1">
<span class="text-base-content/80 text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-price-count",
"min": 15,
"max": 159
}'
class="text-5xl font-semibold">
15
</p>
</div>
<ul class="text-sm space-y-3">
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Unlimited responses</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Unlimited forms & surveys</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Instagram profile page</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Google Docs integration</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Custom Landing page</span>
</li>
</ul>
<button class="btn btn-sm btn-primary mt-4">UPGRADE</button>
</div>
</div>
<div class="card border-base-content/20 border shadow-none">
<div class="card-body gap-3 text-center">
<div>
<span class="text-base-content text-xl font-medium">Enterprise</span>
<p class="text-sm truncate">Solution for big organizations</p>
</div>
<div class="text-primary flex justify-center gap-x-1">
<span class="text-base-content/80 text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-price-count",
"min": 79,
"max": 999
}'
class="text-5xl font-semibold">
79
</p>
</div>
<ul class="text-sm space-y-3">
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">PayPal payments</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Logic Jumps</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">File upload with 5GB storage</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Custom domain support</span>
</li>
<li class="flex items-center space-x-3 rtl:space-x-reverse">
<span class="bg-primary/20 text-primary flex items-center justify-center rounded-full p-1">
<span class="icon-[tabler--arrow-right] size-4 rtl:rotate-180"></span>
</span>
<span class="text-base-content/80 truncate">Stripe integration</span>
</li>
</ul>
<button class="btn btn-outline btn-sm btn-primary mt-4">UPGRADE</button>
</div>
</div>
</div>
destroy
method is provided to facilitate the destruction of a toggle count.Free
0
All the basics for the business that are just getting started!
Essential
15
All the essentials for the business that need some added support!
Standard
60
All the standards for the businesses that need more growth.
Pro
100
All the advanced features with pro support & customizations!
<div id="toggle-count-destroy">
<div class="mb-3 flex justify-center">
<div id="toggle-count-example" class="border-base-content/20 flex gap-0.5 rounded-btn border p-0.5">
<label for="toggle-count-monthly-based" class="btn btn-sm btn-text has-[:checked]:btn-active">
<span>Monthly</span>
<input id="toggle-count-monthly-based" name="toggle-count-example" type="radio" class="hidden" checked="" />
</label>
<label for="toggle-count-annual-based" class="btn btn-sm btn-text has-[:checked]:btn-active">
<span>Annually</span>
<input id="toggle-count-annual-based" name="toggle-count-example" type="radio" class="hidden" />
</label>
</div>
</div>
<div class="border-base-content/20 grid grid-cols-1 items-center rounded-xl border sm:grid-cols-2 md:grid-cols-4">
<div class="flex flex-col items-center justify-center gap-2 p-4">
<p class="mb-1 font-medium">Free</p>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count-example",
"min": 0,
"max": 0
}'
class="text-3xl sm:text-5xl">
0
</p>
</div>
<p class="text-sm text-center">All the basics for the business that are just getting started!</p>
</div>
<div class="flex flex-col items-center justify-center gap-2 p-4">
<p class="mb-1 font-medium">Essential</p>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count-example",
"min": 15,
"max": 159
}'
class="text-3xl sm:text-5xl">
15
</p>
</div>
<p class="text-sm text-center">All the essentials for the business that need some added support!</p>
</div>
<div class="flex flex-col items-center justify-center gap-2 p-4">
<div class="flex justify-between">
<p class="mb-1 font-medium">Standard</p>
</div>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count-example",
"min": 60,
"max": 699
}'
class="text-3xl sm:text-5xl">
60
</p>
</div>
<p class="text-sm text-center">All the standards for the businesses that need more growth.</p>
</div>
<div class="flex flex-col items-center justify-center gap-2 p-4">
<p class="mb-1 font-medium">Pro</p>
<div class="text-base-content flex gap-x-1 font-semibold">
<span class="text-xl">$</span>
<p
data-toggle-count='{
"target": "#toggle-count-example",
"min": 100,
"max": 999
}'
class="text-3xl sm:text-5xl">
100
</p>
</div>
<p class="text-sm text-center">All the advanced features with pro support & customizations!</p>
</div>
</div>
</div>
<div class="mt-4 flex gap-3">
<button class="btn btn-primary" id="destroy-btn">Destroy</button>
<button class="btn btn-primary" id="reinit-btn" disabled>Reinitialize</button>
</div>
<script>
window.addEventListener('load', () => {
// Destroy and reinit variables
const toggleCounts = document.querySelectorAll('#toggle-count-destroy [data-toggle-count]')
const destroyBtn = document.querySelector('#destroy-btn')
const reinitBtn = document.querySelector('#reinit-btn')
// Destroy usage
destroyBtn.addEventListener('click', () => {
toggleCounts.forEach(el => {
const { element } = HSToggleCount.getInstance(el, true)
element.destroy()
})
destroyBtn.setAttribute('disabled', 'disabled')
reinitBtn.removeAttribute('disabled')
})
// Reinit usage
reinitBtn.addEventListener('click', () => {
HSToggleCount.autoInit()
reinitBtn.setAttribute('disabled', 'disabled')
destroyBtn.removeAttribute('disabled')
})
})
</script>
Assign the value of the data-toggle-count
attribute as an object. Within this object, set the duration
option to number
to set counting speed(animation). By default, its value is 700
.
10
<div class="card w-40">
<div class="text-base-content card-body font-semibold">
<p
data-toggle-count='{
"target": "#toggle-duration-usage",
"min": 10,
"max": 100,
"duration":100
}'
class="mb-2 text-center text-5xl">
10
</p>
<input id="toggle-duration-usage" name="toggle-count-method" type="checkbox" class="switch switch-primary mx-auto" aria-label="toggle count" />
</div>
</div>
PARAMETERS | DESCRIPTION | OPTIONS | DEFAULT VALUE |
---|---|---|---|
data-toggle-count | Activate a Toggle Count by specifying on an element. | - | - |
:target (required) | Specifies default number. | string | - |
:min | Specifies the target element to copy. The value must be a valid selector. | number | 0 |
:max | Specifies the number to which the count up will go. | number | 0 |
:duration | Counting speed (animation). | number | 700 |
The HSToggleCount
object is contained within the global window
object.
METHOD | DESCRIPTION |
---|---|
PUBLIC METHODS | |
countUp() | Force count up. |
countDown() | Force count down. |
destroy() | Destroys the instance, removes generated markup (if any), removes added classes and attributes. |
STATIC METHODS | |
HSToggleCount.getInstance(target, isInstance) | Returns the element associated to the target .
|
Assign an ID to the button containing the data-toggle-count
attribute, as demonstrated in the public method. To explore additional methods, you can copy them into the console.
10
<div class="card w-40">
<div class="text-base-content card-body font-semibold">
<input id="toggle-input-method" name="toggle-count-method" type="checkbox" class="hidden" />
<p
id="toggle-count-method"
data-toggle-count='{
"target": "#toggle-input-method",
"min": 10,
"max": 100
}'
class="text-center text-5xl">
10
</p>
</div>
<div class="flex justify-between p-2 pt-0">
<button id="count-down-method" class="btn btn-soft btn-error btn-square" aria-label="decrement">
<span class="icon-[tabler--minus]"></span>
</button>
<button id="count-up-method" class="btn btn-soft btn-primary btn-square" aria-label="increment">
<span class="icon-[tabler--plus]"></span>
</button>
</div>
</div>
<script>
window.addEventListener('load', function () {
const toggleCount = new HSToggleCount(document.querySelector('#toggle-count-method'))
const countUpBtn = document.querySelector('#count-up-method')
const countDownBtn = document.querySelector('#count-down-method')
countUpBtn.addEventListener('click', () => {
toggleCount.countUp()
})
countDownBtn.addEventListener('click', () => {
toggleCount.countDown()
})
})
</script>
Force count up (public method).
// This method is used in above example.
const toggleCount = new HSToggleCount(document.querySelector('#toggle-count-method'));
const countUpBtn = document.querySelector('#count-up-method');
const countDownBtn = document.querySelector('#count-down-method');
countUpBtn.addEventListener('click', () => {
toggleCount.countUp();
});
countDownBtn.addEventListener('click', () => {
toggleCount.countDown();
});
Force count up (mixed).
const { element } = HSToggleCount.getInstance('#toggle-count-method', true);
const countUpBtn = document.querySelector('#count-up-method');
countUpBtn.addEventListener('click', () => {
element.countUp();
});
Destroy instance.
const { element } = HSToggleCount.getInstance('#toggle-count-destroy', true);
const destroyBtn = document.querySelector('#destroy-btn');
destroyBtn.addEventListener('click', () => {
element.destroy();
});