Statistics
Highlighting numbers of things
Overview
Sometimes we need to feature numbers.
<div class="stat-container"> <span class="stat-title"> Cookies in the Jar </span> <span class="stat-number"> 12 </span> </div>
Colors
Use the classes .stat-red
, .stat-orange
, .stat-green
, .stat-blue
to add color.
In general:
- Red is used for numbers that show poor performance, need attention, failure, etc.
- Orange is used for numbers that are borderline as far as importance/attention or success/failure.
- Green is used to show positive growth, exceeding expectations, success, etc.
- Blue is a sort of neutral number.
<div class="stat-container stat-red"> <span class="stat-title"> Fish in the pond </span> <span class="stat-number"> 1232 </span> </div>
Sizes
Use .stat-medium
to make things a bit more compact. Use .stat-small
to make them small and inline.
Default
Medium
Small
<div class="stat-container stat-small stat-blue"> <span class="stat-title"> Ayes </span> <span class="stat-number"> 25 </span> </div>
Links
Make the whole stat link somewhere by replacing the div with an anchor tag.
<a class="stat-container stat-green" href="#"> <span class="stat-title"> Fish in the pond </span> <span class="stat-number"> 1232 </span> </a>
Icons, Change, and Labels
Stats can have icons, we can display how much the number has changed, and we can add labels for further description.
Icons
Change
<h3>Icons</h3> <div class="stat-container stat-blue"> <span class="stat-title"> Puppies running around </span> <span class="stat-icon glyphicons glyphicons-dog"></span> <span class="stat-number"> 31 </span> <span class="stat-label"> The puppies are monitored by trained professionals. </span> </div> <h3>Change</h3> <div class="stat-container stat-red"> <span class="stat-title"> Fish in the pond </span> <span class="stat-number"> 1232 </span> <span class="stat-difference"> -30% </span> <span class="stat-label"> Number of koi fish in this pond. </span> </div>
Buttons
Buttons can be added next to the title.
<div class="stat-container stat-green"> <span class="stat-title"> <!-- note span around title text --> <span> Fish in the pond </span> <!-- button goes here --> <a href="#" class="js-fish-data-toggle"> <span class="glyphicons glyphicons-table"></span> View Data </a> </span> <span class="stat-number"> 1232 </span> </div>
Nesting and Grouping
Stats can be nested inside of stats, and grids of stats can be created by putting them inside a .stats-flex
container. Putting the stats inside a .stat-group
container removes the border, which can work to make nested stats less busy.
<div class="stat-container"> <div class="stat-title"> Critters in the Aquarium </div> <div class="stat-group stats-flex"> <div class="stat-container stat-medium"> <div class="stat-title"> Goldfish </div> <div class="stat-number"> 2 </div> <div class="stat-label"> They are getting big! </div> </div> <div class="stat-container stat-medium"> <div class="stat-title"> Cherry Shrimp </div> <div class="stat-number"> 8 </div> <div class="stat-label"> Hopefully the fish don't eat them. </div> </div> <div class="stat-container stat-medium"> <div class="stat-title"> Mystery Snails </div> <div class="stat-number"> 3 </div> <div class="stat-label"> Cleaning all the surfaces. </div> </div> </div> </div>