JSFiddle - React, Tailwind, and code Playground
by spinal007
HTML
<link rel="stylesheet" href="http://dl.dropbox.com/u/1722364/Stack%20Overflow/jquery-ui.css">
<div id="debug">
jQuery UI will be applied to these buttons after a 5 second timeout
</div>
<div class="example">
This is what happens with the button class to
emulate jQuery UI <b>without running jQuery UI</b>
<br/>
<a class="button" href="#"><a/></a>
<button class="button" type="button"><button/></button>
<input class="button" type="button" value="<input/>"/>
<div style="padding:10px 0 0 40px; color:red;">NB: this is pure css emulation using the "button" class, no javascript!</div>
</div>
<div class="example">
This is what happens when you use the button class to
<b>emulate jQuery UI until it loads</b>
<br/>
<a class="button apply-ui-after-delay" href="javascript:;"><a/></a>
<button class="button apply-ui-after-delay" type="button"><button/></button>
<input class="button apply-ui-after-delay" type="button" value="<input/>"/>
</div>
<div class="example">
This is what we'd get if we apply the UI classes ahead of time
<br/>
<a class="apply-ui-after-delay ui ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" href="javascript:;"><a/></a>
<button class="apply-ui-after-delay ui ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"><button/></button>
<input class="apply-ui-after-delay ui ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" value="<input/>"/>
</div>
<div class="example">
And this is the worst case scenario...
<br/>
<a class="apply-ui-after-delay" href="javascript:;"><a/></a>
<button class="apply-ui-after-delay"><button/></button>
<input class="apply-ui-after-delay" type="button" value="<input/>"/>
</div>
<div class="example">
<b>NB.: If you want the css to apply to all buttons and not only the ones with the "button"...
CSS
/* ignore this css, I'm just making the demo readable */
body{padding:20px;font-size:9.0pt;font-family:Arial;}
.example{border-top:#ccc dotted 2px;margin-bottom:15px;padding-top:10px;}
#debug{padding:10px;background:#fc0;color:#900;font-weight:bold;}
/* the css you need is below this line */
.button{
cursor:pointer;
display:inline-block;
line-height:1.4;
margin: 0 0.1em 0 0;
padding: 0.3em 1em 0.4em;
border: 1px solid #ccc;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
color: #666;
/* Thanks to http://www.colorzilla.com/gradient-editor/ */
background: #ffffff; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2Y2ZjhmOSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2U1ZWJlZSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iI2Q3ZGVlMyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmNWY3ZjkiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #ffffff 0%, #e5ebee 50%, #d7dee3 51%, #f5f7f9 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(50%,#e5ebee), color-stop(51%,#d7dee3), color-stop(100%,#f5f7f9)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%); /* Chrome10+,Safari5.1+...
JavaScript
setTimeout(function() {
$('#debug').html('Pausing so you can see the difference');
alert('jQuery UI is going to do its thing now, watch closely!');
$('#debug').html('Invoking jQuery UI now!');
$('.apply-ui-after-delay').removeClass('button').button();
$('#debug').html('jQuery UI has been applied to this page')
}, 4000);