From our sponsor: Ready to show your plugin skills? Enter the Penpot Plugins Contest (Nov 15-Dec 15) to win cash prizes!
Today we’d like to share some progress button styles with you. You surely know “Ladda” by Hakim El Hattab, a UI concept that indicates progress directly on the button that invokes a loading action. Some of the buttons have a built-in progress bar and today we’d like to explore that idea with some creative progress button styles. Using perspective will allow us to create some fun 3D effects besides the flat “filling” styles. For a complete solution, please take a better look at Ladda.
Please note that we’ll be using transitions on pseudo-elements which are still not supported in some browsers (e.g. Safari and Mobile Safari).
Also note that we need transform-style: preserve-3d
support for the 3D styles, which neither IE10 nor IE11 support.
With the script that we’ve created for showing the button styles, we take a simple button markup
<button class="progress-button" data-style="rotate-angle-bottom" data-perspective data-horizontal>Submit</button>
and transform it into the following structure:
<button class="progress-button" data-style="rotate-angle-bottom" data-perspective data-horizontal> <span class="progress-wrap"> <span class="content">Submit</span> <span class="progress"> <span class="progress-inner"></span> </span> </span> </button>
If we don’t set the data-perspective
attribute, then we’ll make this structure:
<button class="progress-button" data-style="fill" data-horizontal> <span class="content">Submit</span> <span class="progress"> <span class="progress-inner"></span> </span> </button>
We also indicate if we have a style that needs horizontal or vertical progress bar filling. This will be used in our CSS to specify the regarding styles.
The following styles are the general and common styles for all buttons (note that perspective styles are only needed for the buttons with 3D transforms):
*, *:after, *::before { box-sizing: border-box; } @font-face { font-weight: normal; font-style: normal; font-family: 'icomoon'; src:url('../fonts/icomoon/icomoon.eot'); src:url('../fonts/icomoon/icomoon.eot?#iefix') format('embedded-opentype'), url('../fonts/icomoon/icomoon.ttf') format('truetype'), url('../fonts/icomoon/icomoon.woff') format('woff'), url('../fonts/icomoon/icomoon.svg#icomoon') format('svg'); } .progress-button { position: relative; display: inline-block; padding: 0 60px; outline: none; border: none; background: #1d9650; color: #fff; text-transform: uppercase; letter-spacing: 1px; font-size: 1em; line-height: 4; } .progress-button[disabled], .progress-button[disabled].state-loading { cursor: default; } .progress-button .content { position: relative; display: block; } .progress-button .content::before, .progress-button .content::after { position: absolute; right: 20px; color: #0e7138; font-family: "icomoon"; opacity: 0; transition: opacity 0.3s 0.3s; } .progress-button .content::before { content: "e600"; /* Checkmark for success */ } .progress-button .content::after { content: "e601"; /* Cross for error */ } .progress-button.state-success .content::before, .progress-button.state-error .content::after { opacity: 1; } .notransition { transition: none !important; } .progress-button .progress { background: #148544; } .progress-button .progress-inner { position: absolute; left: 0; background: #0e7138; } .progress-button[data-horizontal] .progress-inner { top: 0; width: 0; height: 100%; transition: width 0.3s, opacity 0.3s; } .progress-button[data-vertical] .progress-inner { bottom: 0; width: 100%; height: 0; transition: height 0.3s, opacity 0.3s; } /* Necessary styles for buttons with 3D transforms */ .progress-button[data-perspective] { position: relative; display: inline-block; padding: 0; background: transparent; perspective: 900px; } .progress-button[data-perspective] .content { padding: 0 60px; background: #1d9650; } .progress-button[data-perspective] .progress-wrap { display: block; transition: transform 0.2s; transform-style: preserve-3d; } .progress-button[data-perspective] .content, .progress-button[data-perspective] .progress { outline: 1px solid rgba(0,0,0,0); /* Smoothen jagged edges in FF */ }
We are using the pseudo-elements ::before and ::after for the success or error icons which we fade in once loading is finished. The span
with the class progress is used as the main wrapper for the progress bar itself which is the span
with class progress-inner. Sometimes we use the progress span
with a background color, while other times we will just style the child span
. We’ll also provide some general styles for the vertical and horizontal case.
Note that for the 3D examples, we’ll use the button as a “shell” that will serve to add the perspective value. The content span will contain the button styles like the background color and the padding, and everything will be wrapped into a span
with the class progress-wrap which will be the element that we transform.
Tiny break: 📬 Want to stay up to date with frontend and trends in web design? Subscribe and get our Collective newsletter twice a tweek.
An example of an individual button style is the following:
/* Rotate bottom 3d */ /* ====================== */ .progress-button[data-style="rotate-angle-bottom"] .progress { position: absolute; top: 100%; left: 0; width: 100%; height: 20px; box-shadow: 0 -1px 0 #148544; /* fix the blurriness that causes a gap */ transform: rotateX(-90deg); transform-origin: 50% 0%; } .progress-button[data-style="rotate-angle-bottom"].state-loading .progress-wrap { transform: rotateX(45deg); }
The button will have one of the three states (or none): state-loading, state-success and state-error.
For browsers that don’t support necessary properties, we’ll provide the default fallback of the first style (fill horizontal).
Icons are by IcoMoon and the icon font was created with the IcoMoon app.
We hope that you find these button styles inspiring and useful!
Thanks Mary,
Awesome buttons. Great stuff!
Love these!! =D
Very cool! I don’t usually comment, but have been following your blog for years, and always excited to see what you will come up with next, great stuff!
Nicest demos 🙂
Stunning!
I guess I don’t need Ladda plugin anymore 🙂 (http://lab.hakim.se/ladda/)
Thanks, Mary. How it will works with real loading? Should I manual set length of an element (for uploading on server for example)?
same wonder i have
Wow thats real creative! i like! keep up your good work!
thks! very Cool!!
ck ck ck…
Great article!! but how do i go about this adding this to a simple ajax contact form? or is it only for file uploading?
Awesome demo, thanks! One question though, which is the best way to control the loading progress, for example, using Ajax to load an image. Which would be the best way to link JavaScript in with this?
Awesome!. Thank you.
Great article! Thank you!
hohhooww! marvellous!
Awesome buttons.!! will be feature in my future projects. Thanks a ton for sharing with us.
Thanks for sharing these great meaningfull alternatives!
SO SWEET!
Looks really, really nice.
I would love a tutorial on how to utilize these loading buttons in a form, to make them work properly! 🙂
Unique on web. Haven’t seen these effect anywhere. Mary Lou you rock 😉
Transitions on pseudo-elements work in Safari 7.0 and Mobile Safari in iOS 7 (finally!) 🙂
Is these feature can combine with php?
Nice work 🙂
Awesome work 🙂
Awesome, Thanks for sharing with us !!!
Amazing UI animations
Awesome!!
Another Awesome Play in Playground by Great Mary Lou
If you’re using jQuery to generate it dynamically prepare for it not to work, it automatically removes the span tags inside the button because it doesnt meet the HTML spec.
How do you get those amazing ideas!!??
Awesome 😀
Very fantastic styles. I was using menu control to create progress bar. But, their styles are limited. And comparing to yours, I found the progress bar so creative and the script so marvelous.
Works great on my iPad Air’s Safari! 🙂
They js that is used causes an issue that doesn’t allow to submit on Chrome. Only browser, I’ve been having issues with.
Awesome!!!
How can I integrate this with AJAX ? I want animate my send-mail button.
I love these so much, flat vector style and very functional and space saving.
You make web a better place. I’m stunned every time I see something from you, and I’ve learnt so much, Thank you!
Awesome work, thanks a lot!
Same as Danilo Vaz i would like to know, how to integrate this with AJAX. Have I change transition-duration or … ?
Nice, how to use this in contact form?
Thank you
How can I make it link to another html if I use this? Help! ;o;
How can i display the cross instead of the V
YOU GENIUS!! 🙂
How do you use this in a contact form? 🙂 Thank you!!
Hi !
I try to use your submit on my form but i’ve a problem 🙁
I use required on my fields, i try to do not activate the effect of submit if required appears. is it possible to do it ?
Olá, sou novo aqui no site e já estou gostando de mais.
Tô com uma dúvida: Como é que eu faço redirecionar para outra página após o término do progresso?
Quero que quando eu clicar no botão, o progresso acabe e eu seja redirecionado.
Atenciosamente, Vitor.
Hello, I’m new here on the site and I’m enjoying it more.
‘m With a doubt: How do I redirect to another page after the progress?
I want that when I Vclick the button, the progress finish and I will be redirected.
Regards, Vitor.
For anyone from you, who’s searching angular version of these buttons, I have created one: https://github.com/akveo/angular-progress-button-styles
Good day, I want to ask how can I use this in form as a submit? I’ve tried to remake it but it didn’t work. Thank you
CHALLENGE,Is there any way to use this these perfect buttons as an upload button where the progress bar does show the condition of the uploading file(how far the uploading goes)
I warmly welcome,
How can I add the code to change the text?
Hi there,
Has anyone been able to include form validation? It doesn’t seem to work, as it’s a button tag rather than an input submit. Other than that, it works beautifully. 🙂
Has anyone had any luck getting this plugin to work with Contact Form 7?
When I set it up, the button animates, but the form no longer submits.
Nice article! I’ll have to try this when I get to my computer! 🙂
I’ll try it, when I get my own Computer!