1.0.0-beta.0 • Published 5 years ago

steller-css v1.0.0-beta.0

Weekly downloads
36
License
MIT
Repository
-
Last release
5 years ago

Steller CSS

CircleCI branch npm version npm NPM

Steller is a utility-first CSS framework that serves as the foundation of your application's design system. It includes built-in smart defaults for building responsive, accesible, and visually consistent user interfaces. Unlike other CSS frameworks, Steller has no opinion on the actual end appearance of your application, it is simply a bridge for your design system and your application's styling.

Open-source development of Steller is proudly sponsored by Snap! Raise.

Features

  • Simple configuration & setup ⚙️
  • Grid system built with CSS Grid 📏
  • Sass based ✨
  • Encourages mobile-first development 📱
  • Extensible module system 🚀
  • Zero dependencies 🙌

Installation

npm i steller-css
yarn add steller-css

Usage

In you index.scss or equivilent, import steller-css.

// Assuming you are using webpack
@import '~steller-css/index'; // StellerCSS

Example Projects

Config

All config variables are optional to define as they already have default values. You can take a look at them here.

It is recommended to make a steller-config.scss file to be the centralized configuration file. Feel free to name this anything.

@import 'steller-config'; // Your config
@import '~steller-css/index'; // StellerCSS

Check out this example theme configuration file and feel free to copy/paste it into yours. The values are the same as the defaults above, but this config is your application's design system so get in there make it your own!

Colors

$steller-colors: (
  // brand
  'primary': #586f7c,
  'secondary': #b8dbd9,

  // accents
  'dwight-schrute': #0FF1C3,
  'a-song-of-this-and-fire': #1CE,
);

Typogrpahy

$steller-font-families: (
  'accent': cursive,
);

$steller-font-sizes: (
  'xs': 0.75rem,
  'sm': 0.875rem,
  'md': 1rem,
  'lg': 1.5,
  'xl': 1.875rem,
  '2xl': 2.25rem,
  '3xl': 3rem,
  '4xl': 3.75rem,
);

$steller-font-weights:(
  'bold': 700,
  'medium': 500,
  'regular': 400,
  'light': 300,
  'thin': 100,
);

$steller-leadings: (
  'sm': 1.25rem,
  'md': 1.5rem,
  'lg': 1.75rem,
  'xl': 2rem,
);

$steller-letter-spacings: (
  'tight': -0.05rem,
  'normal': 0,
  'wide': 0.05rem,
);

Breakpoints

$steller-breakpoints: (
  'sm': 320px,
  'md': 600px,
  'lg': 1024px,
);

Container

$steller-container-width: 1140px;
$steller-container-paddings: (
  'sm': (padding: 8px),
  'md': (padding: 12px),
  'lg': (padding: 16px),
);

Grid

$steller-grid-columns: 12;

$steller-column-gutters: (
  'sm': 16px,
  'md': 16px,
  'lg': 24px,
);

$steller-row-gutters: (
  'sm': 8px,
  'md': 8px,
  'lg': 16px,
);

Spacing

$steller-spacings: (
  'xs': 4px,
  'sm': 8px,
  'md': 16px,
  'lg': 24px,
  'xl': 32px,
  '2xl': 48px,
  '3xl': 64px,
);

Borders

$steller-border-radiuses: (
  'sm': 5px,
  'md': 10px,
  'lg': 15px,
  'xl': 20px,
);

$steller-border-widths: (
  'xs': 1px,
  'sm': 2px,
  'md': 4px,
  'lg': 6px,
  'xl': 8px,
);

Motion

$steller-transition-properties: (
  all,
  width,
  height,
  transform,
  opacity,
  border,
  background,
  background-color,
  box-shadow,
  margin,
  padding,
  visibility,
);
$steller-durations: (
  'extra-slow': 500ms,
  'slow': 400ms,
  'normal': 300ms,
  'fast': 200ms,
  'extra-fast': 100ms,
);

Effects

$steller-box-shadows: (
  'sm': 0 7px 15px 0 rgba(0, 0, 0, 0.11), 0 1px 8px 0 rgba(0, 0, 0, 0.06),
  'md': 0 10px 20px 0 rgba(0, 0, 0, 0.22), 0 3px 12px 0 rgba(0, 0, 0, 0.07),
  'lg': 0 15px 30px 0 rgba(0, 0, 0, 0.33), 0 5px 15px 0 rgba(0, 0, 0, 0.1),
);

Gradients

$steller-gradients: (
  'cta-primary': linear-gradient(to right, #55c1ff, #5863f8),
);

Utility Classes

Container

ClassProperties
.containermargin: 0 auto; max-width: $container-width; position: relative;
<div class="container"></div>

Grid

ClassProperties
.griddisplay: grid; grid-template-columns: repeat($grid-columns, 1fr);
.{$breakpont}:col-{$span}grid-column: span $span;
.{$breakpont}:row-{$span}grid-row: span $span;
.{$breakpont}:col-{$span}-start-{$grid-column-start}grid-column: $grid-column-start / span $span;
<div class="grid">
  <div class="col-12 md:col-6"></div>
  <div class="col-12 md:col-6"></div>
</div>

Typography

ClassProperties
.font-{$family}font-family: $font-family
.font-size-{$size}font-size: $size
.font-weight-{$weight}font-size: $weight
.leading-{$leading}line-height: $leading
.italicfont-style: italic;
.underlinetext-decoration: underline;
.no-underlinetext-decoration: none;
.lowercasetext-transform: lowercase;
.uppercasetext-transform: uppercase;
.capitalizetext-transform: captialize;
.letter-spacing-tightletter-spacing: -0.05em;
.letter-spacing-normalletter-spacing: 0em;
.letter-spacing-wideletter-spacing: 0.05em;
.list-resetlist-style: none; padding: 0;
.whitespace-normalwhite-space: normal;
.whitespace-no-wrapwhite-space: nowrap;
.whitespace-prewhite-space: pre;
.whitespace-pre-linewhite-space: pre-line;
.whitespace-pre-wrapwhite-space: pre-wrap;
.break-wordword-wrap: break-word;
.break-wordword-wrap: normal;
.truncateoverflow: hidden; text-overflow: ellipses; white-space: nowrap;
<!-- font size -->
<div class="font-size-3xl"></div>

<!-- font weight -->
<div class="font-weight-bold"></div>

<!-- leading (line height) -->
<div class="leading-sm"></div>

Color

ClassProperties
.text-{$color}color: $color;
.bg-{$color}background-color: $color;
$steller-colors: (
  'my-color-name': #586f7c,
);
<div class="text-my-color-name"></div>
<div class="bg-my-color-name"></div>

Layout

ClassProperties
.blockdisplay: block;
.inline-blockdisplay: inline-block;
.inlinedisplay: inline;
.hiddendisplay: none;
.text-centertext-align: center;
.text-lefttext-align: left;
.text-righttext-align: right;
.text-justifytext-align: justify;
.float-leftfloat: left;
.float-rightfloat: right;
.float-nonefloat: none;
.staticposition: static;
.fixedposition: fixed;
.absoluteposition: absolute;
.relativeposition: relative;
.stickyposition: sticky;
.pintop: 0; right: 0; bottom: 0; left: 0;
.pin-ttop: 0;
.pin-rright: 0;
.pin-bbottom: 0;
.pib-lleft: 0;
.visiblevisibility: visible;
.invisiblevisibility: hidden;
.z-0z-index: 0;
.z-1z-index: 1;
.z-2z-index: 2;
.z-10z-index: 10;
.z-20z-index: 20;
.z-maxz-index: 2147483647;
.vertical-align-baselinevertical-align: baseline;
.vertical-align-topvertical-align: top;
.vertical-align-middlevertical-align: middle;
.vertical-align-bottomvertical-align: bottom;
.vertical-align-text-topvertical-align: text-top;
.vertical-align-text-bottomvertical-align: text-bottom;

Spacing

ClassProperties
.m-{$size}margin: $size;
.p-{$size}padding: $size;
.mx-{$size}margin-left: $size; margin-right: $size;
.px-{$size}padding-left: $size; padding-right: $size;
.my-{$size}margin-top: $size; margin-bottom: $size;
.py-{$size}padding-top: $size; padding-bottom: $size;
.mt-{$size}margin-top: $size;
.pt-{$size}padding-top: $size;
.mr-{$size}margin-right: $size;
.pr-{$size}padding-right: $size;
.mb-{$size}margin-bottom: $size;
.pb-{$size}padding-bottom: $size;
.ml-{$size}margin-left: $size;
.pl-{$size}padding-left: $size;
  • Spacing Sizes: ('xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl')
<!-- margin all sides large -->
<div class="m-lg"></div>

<!-- padding top/bottom small -->
<div class="py-sm"></div>

<!-- margin top 2xl -->
<div class="mt-2xl"></div>

<!-- padding right extra small -->
<div class="pr-xs"></div>

Flexbox

ClassProperties
.flexdisplay: flex;
.inline-flexdisplay: inline-flex;
.flex-rowflex-direction: row;
.flex-colflex-direction: col;
.flex-row-reverseflex-direction: row-reverse;
.flex-col-reverseflex-direction: col-reverse;
.flex-wrapflex-wrap: wrap;
.flex-no-wrapflex-wrap: nowrap;
.flex-wrap-reverseflex-wrap: wrap-reverse;
.items-strechalign-items: stretch;
.items-startalign-items: flex-start;
.items-centeralign-items: center;
.items-endalign-items: flex-end;
.items-baselinealign-items: baseline;
.content-startalign-content: flex-start;
.content-centeralign-content: center;
.content-endalign-content: flex-end;
.content-betwenalign-content: space-between;
.content-aroundalign-content: space-around;
.self-autoalign-self: auto;
.self-startalign-self: flex-start;
.self-centeralign-self: center;
.self-endalign-self: flex-end;
.self-stretchalign-self: stretch;
.justify-startjustify-content: flex-start;
.justify-centerjustify-content: center;
.justify-endjustify-content: flex-end;
.flex-initialflex: initial;
.flex-1flex: 1;
.flex-2flex: 2;
.flex-autoflex: auto;
.flex-noneflex: none;
.flex-growflex-grow: 1;
.flex-shrinkflex-shrink: 1;
.flex-no-growflex-grow: 0;
.flex-no-shrinkflex-shrink: 0;

Sizing

ClassProperties
.w-autowidth: auto;
.w-fullwidth: 100%;
.w-screenwidth: 100vw;
.w-1pxwidth: 1px;
.h-autoheight: auto;
.h-fullheight: 100%;
.h-screenheight: 100vh;
.h-1pxheight: 1px;
.min-w-automin-width: auto;
.min-w-fullmin-width: 100%;
.min-w-screenmin-width: 100vw;
.min-w-1pxmin-width: 1px;
.min-w-0min-width: 0;
.min-h-automin-height: auto;
.min-h-fullmin-height: 100%;
.min-h-screenmin-height: 100vh;
.min-h-1pxmin-height: 1px;
.min-h-0min-height: 0;
.max-w-automax-width: auto;
.max-w-fullmax-width: 100%;
.max-w-screenmax-width: 100vw;
.max-w-1pxmax-width: 1px;
.max-w-0max-width: 0;
.max-h-automax-height: auto;
.max-h-fullmax-height: 100%;
.max-h-screenmax-height: 100vh;
.max-h-1pxmax-height: 1px;
.max-h-0max-height: 0;

Borders

ClassProperties
.rounded-{$size}border-radius: $size;
.border-{$color}border-color: auto;
.border-{$corner}-{$radius}border-{$corner}-radius: $radius;
.border-{$width}border-width: $width;
.border-{$side}-{$width}border-{$side}-width: $width;
.border-solidborder-style: solid;
.border-dashedborder-style: dashed;
.border-dottedborder-style: dotted;
.border-insetborder-style: inset;
.border-outsetborder-style: outset;
  • Border Radius Sizes: ('sm', 'md', 'lg', 'xl')
  • Border Width Sizes: ('xs', 'sm', 'md', 'lg', 'xl')
$steller-colors: (
  'my-color-name': #586f7c,
);
<!-- border radius (all 4 corners) -->
<div class="rounded-lg"></div>

<!-- border top -->
<div class="border-top-xs border-my-color-name border-solid"></div>

<!-- rounded bottom right corner only -->
<div class="rounded-br-sm"></div>

Effects

ClassProperties
.shadow-{$size}box-shadow: $size;
.opacity-100opacity: 1;
.opacity-75opacity: 0.75;
.opacity-50opacity: 0.5;
.opacity-25opacity: 0.25;
.opacity-0opacity: 0;
  • Box Shadow Sizes: ('sm', 'md', 'lg')
<div class="shadow-md"></div>

Gradients

ClassProperties
.bg-gradient-{$gradient-name}background-image: $gradient;
$steller-colors: (
  'my-color-name': #586f7c,
);
<div class="bg-gradient-my-gradient-name"></div>

Backgrounds

ClassProperties
.bg-attachment-fixedbackground-attachment: fixed;
.bg-attachment-localbackground-attachment: local;
.bg-attachment-scrollbackground-attachment: scroll;
.bg-position-bottombackground-position: bottom;
.bg-position-centerbackground-position: center;
.bg-position-leftbackground-position: left;
.bg-position-left-bottombackground-position: left-bottom;
.bg-position-left-topbackground-position: left-top;
.bg-position-rightbackground-position: right;
.bg-position-right-bottombackground-position: right-bottom;
.bg-position-right-topbackground-position: right-top;
.bg-position-topbackground-position: top;
.bg-repeatbackground-repeat: repeat;
.bg-no-repeatbackground-repeat: no-repeat;
.bg-repeat-xbackground-repeat: repeat-x;
.bg-repeat-ybackground-repeat: repeat-y;
.bg-size-autobackground-size: auto;
.bg-size-coverbackground-size: cover;
.bg-size-containbackground-size: contain;

Interactivity

ClassProperties
.appearance-noneappearance: none;
.cursor-autocursor: auto;
.cursor-defaultcursor: default;
.cursor-pointercursor: pointer;
.cursor-waitcursor: wait;
.cursor-movecursor: move;
.cursor-not-allowedcursor: not-allowed;
.outline-noneoutline: none;
.pointer-events-nonepointer-events: none;
.pointer-events-autopointer-events: auto;
.resize-noneresize: none;
.resizableresize: both;
.resizable-yresize: vertical;
.resizable-xresize: horizontal;
.user-select-textuser-select: text;
.user-select-noneuser-select: none;

Table

ClassProperties
.table-autotable-layout: auto;
.table-fixedtable-layout: fixed;
.border-collapseborder-collapse: collapse;
.border-seperateborder-collapse: separate;

SVG

ClassProperties
.fill-currentfill: currentColor;
.stroke-currentstroke: currentColor;

State Variants

Responsive

For breakpoint specific stylings, add the breakpoint label prefix to the beginning of the class.

<span class="text-success md:text-danger">
  I am naturally the success color,
  but I am the danger color above the medium breakpoint
</span>

Hover

To apply a style on hover, prefix the normal class with hover:.

<span class="hover:underline">
  I am undelrined on hover!
</span>

Focus

To apply a style on focus, prefix the normal class with focus:.

<span class="focus:underline">
  I am undelrined on focus!
</span>

Active

To apply a style on active, prefix the normal class with active:.

<span class="active:underline">
  I am undelrined on active!
</span>

Custom CSS

Within a functional CSS paradigm, you hopefully won't be writing that much custom styling in CSS/SCSS files, but you'll likely need to write some for the occasional complex component or feature. Steller recognizes this and exposes all of your theme config variables as CSS Custom Properties (CSS Variables) to help you.

Your config

$steller-colors: (
  'primary': lightblue,
  'secondary': pink,
);

$steller-font-families: (
  'classy': ('Comic Sans', cursive),
);

Your feature

.some-complex-element {
  background: linear-gradient(var(--color-primary), var(--color-secondary));
  font-family: var(--font-classy);
  font-size: var(--font-size-2xl);
}

Optionally, you can just reference the Steller theme variables directly or use one of the helper sass functions Steller provides.

.foo {
  // finds the color named 'primary' in your $steller-colors theme var
  background-color: color('primary');
  // finds the font family named 'classy' in your $steller-custom-font-families theme var
  font-family: font-family('classy');
}

List of all built-in functions like the above color & font-family example:

  • color()
  • font-family()
  • spacing()
  • border-radius()
  • border-width()
  • box-shadow()
  • breakpoint()
  • column-gutter()
  • row-gutter()
  • gradient()
  • speed()

Extending Steller / Custom Classes

Steller is extensible via first or third-party modules. Simply add a sass map to the $steller-modules variable in your theme conifg (or anywhere before your steller-css import). Example.

$steller-modules: (
  $my-custom-utils,
);

Your module variable should look something along these lines:

$my-custom-utils: (
  'wumbo': font-size: 100px,
  'cant-see-u': (opacity: 0, visibility: hidden),
);
<span class="cant-see-u md:wumbo">
  Custom classes! :tada:
</span>

Classes via steller modules automatically have all prefixed variants available.


Contributors

Roadmap

  • Ship a stable, battle-tested 1.0 version

Steller Family

What is functional/atomic/utility-first CSS?

TailwindCSS vs StellerCSS

The most similar framework to Steller is without a doubt Tailwind CSS. Tailwind is awesome and it was half of the reason I first realized the true power of utility-first CSS to begin with. So why Steller then? At Snap! Raise, we had a couple of primary reasons to roll our own framework.

  • The Grid System. Tailwind doesn't have a built-in grid system and you're kinda stuck with hacking together a flexbox/width percentage solution as shown in their docs. A 12-column grid system is really important to us from both a design and developement perspective. The Steller grid system, which is built on top of CSS Grid, offers a lot more here.
  • Sass vs JS. Tailwind is written in PostCSS which is a tool for transforming styles via JavaScript plugins. Though a very powerfull tool, it is my opinion that it's benefits comes with the trade offs of a more complex setup and steeper learning curve. Our team was already familiar with and using Sass and we wanted to stay within that reliable paradigm. Jumping into a JavaScript file to change your base CSS configuration just seems like a context switch.

Other than that, Steller and Tailwind are pretty much very similar tools. Like previously mentioned, the initial development of Steller was done with Tailwind as a key inspiration.

1.0.0-beta.0

5 years ago

1.0.0-alpha.6

5 years ago

1.0.0-alpha.5

5 years ago

1.0.0-alpha.4

5 years ago

1.0.0-alpha.3

5 years ago

1.0.0-alpha.2

5 years ago

1.0.0-alpha.1

5 years ago

1.0.0-alpha.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.2.0-alpha.0

5 years ago

0.1.6-beta.0

5 years ago

0.1.5

5 years ago

0.1.4-beta.0

5 years ago

0.1.3

5 years ago

0.1.3-beta.0

5 years ago

0.1.2

5 years ago

0.1.1-beta.2

5 years ago

0.1.1-beta.1

5 years ago

0.1.1-beta.0

5 years ago

0.1.0

5 years ago

0.1.0-beta.1

5 years ago

0.1.0-beta.0

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.5-beta.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago