Swatch UI widget
by jorgeluis
HTML
<div class="swatch"><label>Text</label></div>
<div class="swatch"><label>Links</label></div>
<form action="#">
<input class="swatch" type="color">
</form>
<p>The .swatch divs above allow the background to appear through the "opening" behind the type.</p>
<p>The intention is to provide a visual swatch for users to select type styles contrasted with background color.</p>
<p>
The "Aa" would have a click handler that displays a form with type settings for color, font-size, font-family, etc.
</p>
CSS
body{
background: tomato;
font-family: sans-serif;
}
.swatch {
width: 100px;
height: 120px;
position: relative;
background: transparent;
display: inline-block;
overflow: hidden;
box-shadow: 0 1px 5px 0 rgba(0,0,0,0.3);
}
.swatch:before {
content:'';
position:absolute;
top: 5px;
left: 5px;
width: 90px;
height: 90px;
box-shadow: 0px 0 0px 100px #eee;
}
.swatch:after {
content: "Aa";
position: absolute;
top: 0;
left: 0;
width: 100%;
text-align: center;
font-size: 36px;
line-height: 90px;
vertical-align: middle;
color: #fff;
}
label {
position: absolute;
bottom: 5px;
width: 100%;
text-align: center;
}