JSFiddle - React, Tailwind, and code Playground
by Darren Galway
HTML
<div class="card">
<div class="header">
<span class="title">Eggs</span>
<span class="badge">1</span>
</div>
<div class="flex">
<div class="item">
<h2>20</h2>
<span>Protein</span>
</div>
<div class="item">
<h2>32</h2>
<span>carbs</span>
</div>
<div class="item">
<h2>205</h2>
<span>calories</span>
</div>
<div class="item">
<h2>90</h2>
<span>Fat</span>
</div>
</div>
<div class="tools">
<button class="tool__button">Add Portion</button>
<button class="tool__button">Delete Portion</button>
<button class="tool__button">Delete Item</button>
</div>
</div>
SCSS
* {
box-sizing: border-box;
}
body {
font-family: sans-serif;
color: #3e3e3e;
}
.card {
display: flex;
flex-direction: column;
max-width: 375px;
margin: 100px auto;
box-shadow: 0 6px 10px 0 rgba(32,32,32,.05), 0 1px 18px 0 rgba(32,32,32,.06), 0 3px 5px -2px rgba(32,32,32,.1);
border-radius: 3px;
overflow: hidden;
&:hover {
> .tools {
display: flex;
}
}
}
.flex {
display: flex;
padding: 1rem 0;
}
.header {
background: #eee;
display: flex;
justify-content: space-between;
align-items: center;
padding: .5rem 1rem;
}
.title {
font-weight: bold;
}
.badge {
background: lightgreen;
border-radius: 6px;
padding: .5rem;
display: inline-block;
line-height: 1;
min-width: 35px;
text-align: center;
font-size: .85rem;
}
.item {
flex: 1;
background: #fefefe;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
h2 {
font-size: 2rem;
margin-bottom: .25rem;
}
span {
color: #bdbdbd;
text-transform: uppercase;
letter-spacing: .05rem;
font-size: .65rem;
}
&:not(:last-of-type) {
border-right: 1px solid #eee;
}
}
.tools {
display: none;
justify-content: space-between;
border-top: 1px solid #eee;
padding: 1rem;
&__button {
border: 0;
padding: .5rem 1rem;
background: transparent;
}
}