aboutsummaryrefslogtreecommitdiff
path: root/build/aui/index.html
blob: 956b6a9d0185c0b5c92f47d2855f22ef77d1cd44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!doctype html>
<html lang="en" id="top">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="icon" href="data:,">
	<title>Aqua UI CSS Buttons</title>
	<link href="https://bt.ht/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" />
	<style>*{box-sizing:border-box;}body{font-family:sans-serif;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{overflow:auto;}table{text-align:left;width:100%;}</style>
</head>

<nav>
  <a href="#menu">Menu &darr;</a>
</nav>

<main>
<h1>Aqua UI CSS Buttons</h1>
<p>2016-06-28</p>
<p>Though it may feel like nostalgia, the old OS design for Mac was arguably better than the current iteration (as of this writing - High Sierra). I recently designed a quick Dribbble shot showcasing how the older operating system used to have so much more character and depth.</p>
<p><figure>
<img src="/public/images/aqua-ui-css-buttons.webp" alt="Old macOS Buttons">
<figcaption>My initial Dribbble shot, which can be found <a href="https://dribbble.com/shots/4561658-Aqua-Buttons-UI">here</a>.</figcaption>
</figure></p>
<p>Since I've been wanting to dip my toes into more tutorial-based articles (maybe I'll even do some screencasts in the future), I decided to start out simple. Let's walk through how to implement these 'aqua' UI buttons with pure CSS.</p>
<h3>Starting with a basic foundation</h3>
<p>Since this project consists of only two buttons elements, the HTML or <i>skeleton</i> of this project is very straightforward:</p>
<pre><code>&lt;button class=&quot;cancel&quot;&gt;Cancel&lt;/button&gt;
&lt;button class=&quot;confirm&quot;&gt;Confirm&lt;/button&gt;
</code></pre>
<h3>Styling the buttons</h3>
<p>The first step is to remove the browser's default button styling by using the <code>appearance</code> property. This will help avoid having to fight against the browser and minimize our CSS code.</p>
<pre><code>button {
    -webkit-appearance: none;
    -moz-appearance: none;
}
</code></pre>
<p>Next, we apply a fairly simple set of CSS that will be shared across both the confirm and cancel buttons:</p>
<p>(Pay attention to the <code>transition</code> property as we will be returning to that shortly)</p>
<pre><code>button {
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 1px solid #ccc;
    border-radius: 125px;
    box-shadow: inset 0 13px 25px rgba(255,255,255,0.5), 0 3px 5px rgba(0,0,0,0.2), 0 10px 13px rgba(0,0,0,0.1);
    cursor: pointer;
    font-family: 'Lucida Grande', Helvetica, Arial, sans-serif;
    font-size: 2rem;
    margin: 5rem 1rem;
    padding: 1.2rem 4rem;
    position: relative;
    transition: all ease .3s;
}
</code></pre>
<p>Then we separate the specific confirm and cancel button styles into their own class selectors:</p>
<pre><code>button.confirm {
    background: #4A90E2;
    border-color: #3672B6;
    color: #fff;
}
</code></pre>
<pre><code>button.cancel {
    background: #D0D0D0;
    border-color: #B8B8B8;
    color: #6F6F6F;
}
</code></pre>
<h3>Playing with pseudo elements</h3>
<p>Now that the button is styled and structured with basic formatting, it's time to add that classic 'shine' seen in the original Dribbble shot.</p>
<p>The cleanest way to do this is by using the <code>:before</code> pseudo element paired with a linear-gradient background.</p>
<pre><code>button:before {
    background: linear-gradient(rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);
    border-radius: 125px;
    content:'';
    height: 50px;
    left: 4%;
    position: absolute;
    top: 1px;
    transition: all ease .3s;
    width: 92%;
}
</code></pre>
<h3>Adding interaction</h3>
<p>The final step is adding the user hover interaction: (Remember that <code>transition</code> property?)</p>
<pre><code>button:hover {
    box-shadow: inset 0 13px 25px rgba(255,255,255,0.8), 0 3px 5px rgba(0,0,0,0.2), 0 10px 13px rgba(0,0,0,0.2);
    transform: scale(1.02);
}
</code></pre>
<p>That's it!</p>
<h3>See it live on CodePen</h3>
<p>You can view this project on CodePen <a href="https://codepen.io/bradleytaunt/pen/YvKxxm">here</a>.</p>
<p>Feel free to fork it or implement your own!</p>
<footer role="contentinfo">
    <h2>Menu Navigation</h2>
    <ul id="menu">
        <li><a href="/">Home</a></li>
        <li><a href="/projects">Projects</a></li>
        <li><a href="/uses">Uses</a></li>
        <li><a href="/wiki">Wiki</a></li>
        <li><a href="/resume">Resume</a></li>
        <li><a href="/colophon">Colophon</a></li>
        <li><a href="/now">Now</a></li>
        <li><a href="/donate">Donate</a></li>
        <li><a href="/atom.xml">RSS</a></li>
        <li><a href="#top">&uarr; Top of the page</a></li>
    </ul>
    <small>
        Built with <a href="https://git.sr.ht/~bt/barf">barf</a>. <br>
        Maintained with ♥ for the web. <br>
        Proud supporter of <a href="https://usefathom.com/ref/DKHJVX">Fathom</a> &amp; <a href="https://nextdns.io/?from=74d3p3h8">NextDNS</a>. <br>
        The content for this site is <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>.<br> The <a href="https://git.sr.ht/~bt/bt.ht">code for this site</a> is <a href="https://git.sr.ht/~bt/bt.ht/tree/master/item/LICENSE">MIT</a>.
    </small>
</footer>