Core

On this page

The core layer, src/0-core, holds Sassy's settings, the make mixins that generate placeholders, and a few helpers for your own styles. The full reference is in docs/0-core.

Each demo on this page is styled by sass/0-core.sass, compiled to css/0-core.css. Under each demo are its Sass, the CSS that Sassy outputs for it, and its HTML.

Content

A large heading, a lead paragraph, a quote with its source, and a list in a row. Make the window narrower than 1200px and the heading shrinks.

Large heading

An introduction that is larger and lighter than the text after it.

Simplicity is prerequisite for reliability.

Edsger W. Dijkstra
  • Sass
  • CSS
  • HTML
.headline
    @extend %bf-display-4

.intro
    @extend %bf-lead

.quote
    @extend %bf-blockquote

.quote-source
    @extend %bf-blockquote-caption

.tags
    @extend %bf-list-inline
@layer sassy.base {
  @layer core {
    .intro {
      font-size: var(--sassy-lead-font-size, calc(var(--sassy-font-size-base) * 1.25));
      font-weight: var(--sassy-lead-font-weight, 300);
    }
    .headline {
      font-size: min(3.5rem, 1.475rem + 2.7vw);
      font-weight: var(--sassy-display-heading-font-weight, 300);
      line-height: var(--sassy-display-heading-line-height, 1.2);
    }
    .tags {
      list-style: none;
      padding-inline-start: 0;
    }
    .tags > li {
      display: inline-block;
    }
    .tags > li:not(:last-child) {
      margin-inline-end: var(--sassy-list-inline-gap, 0.5rem);
    }
    .quote {
      font-size: var(--sassy-blockquote-font-size, calc(var(--sassy-font-size-base) * 1.25));
    }
    .quote-source {
      color: var(--sassy-blockquote-caption-colour, var(--sassy-muted));
      font-size: var(--sassy-blockquote-caption-font-size, 0.875em);
      margin-block: -1rem 1rem;
    }
    .quote-source::before {
      content: "— ";
    }
  }
}
<h3 class="headline">Large heading</h3>
<p class="intro">An introduction that is larger and lighter than the text after it.</p>

<figure>
    <blockquote class="quote">
        <p>Simplicity is prerequisite for reliability.</p>
    </blockquote>
    <figcaption class="quote-source">Edsger W. Dijkstra</figcaption>
</figure>

<ul class="tags">
    <li>Sass</li>
    <li>CSS</li>
    <li>HTML</li>
</ul>
Docs: Content

Palette colours and transparency

colour() returns any palette colour, and with-alpha() makes any colour transparent - here 60%, so the stripes show through.

A label on a grey 900 background at 60%
@use "sassy/src" as sassy

.tooltip
    @extend %bf-d-inline-block
    @extend %bf-px-3
    @extend %bf-py-2
    @extend %bf-rounded-3
    background-color: sassy.with-alpha(sassy.colour("grey", 900), 0.6)
    color: sassy.colour("grey", 50)
@layer sassy.base {
  @layer utilities {
    .tooltip {
      padding-left: 0.75rem;
      padding-right: 0.75rem;
    }
    .tooltip {
      padding-top: 0.5rem;
      padding-bottom: 0.5rem;
    }
    .tooltip {
      display: inline-block;
    }
    .tooltip {
      border-radius: 0.375rem;
    }
  }
}
.tooltip {
  background-color: color-mix(in oklab, oklch(21% 0.034 264.665deg) 60%, transparent);
  color: oklch(98.5% 0.002 247.839deg);
}
<span class="tooltip">A label on a grey 900 background at 60%</span>
Docs: Functions

Your own breakpoint styles

up() wraps your own styles in a media query for a breakpoint, as Sass cannot @extend inside one.

Make the window narrower than 768px and the text shrinks.

This text is 1rem, and 1.5rem from md upwards.

.hero
    @extend %bf-m-0
    font-size: 1rem

    @include sassy.up(md)
        font-size: 1.5rem
@layer sassy.base {
  @layer utilities {
    .hero {
      margin: 0rem;
    }
  }
}
.hero {
  font-size: 1rem;
}
@media (width >= 768px) {
  .hero {
    font-size: 1.5rem;
  }
}
<p class="hero">This text is 1rem, and 1.5rem from md upwards.</p>
Docs: Mixins

Different values at different breakpoints

up-prop() takes a property, then its value at each breakpoint you name.

The sidebar is full width at first, half from 576px, and a quarter from 992px.

.sidebar
    @extend %bf-bg-grey-200
    @extend %bf-px-4
    @extend %bf-py-3
    @include sassy.up-prop(width (sm: 50%, lg: 25%))
@layer sassy.base {
  @layer utilities {
    .sidebar {
      padding-left: 1rem;
      padding-right: 1rem;
    }
    .sidebar {
      padding-top: 0.75rem;
      padding-bottom: 0.75rem;
    }
    .sidebar {
      background-color: color-mix(in oklab, oklch(92.8% 0.006 264.531deg) var(--sassy-bg-opacity, 100%), transparent);
    }
  }
}
@media (width >= 576px) {
  .sidebar {
    width: 50%;
  }
}
@media (width >= 992px) {
  .sidebar {
    width: 25%;
  }
}
<div class="sidebar">Sidebar</div>
Docs: Mixins

Your own placeholders, in Sassy's style

make-responsive() generates a placeholder for each value and breakpoint, and make-layers() outputs them in Sassy's cascade layers, so each breakpoint beats the one before. This stack has a 0.25rem gap, and 0.5rem from md upwards.

@include sassy.make-layers
    @include sassy.make-responsive("stack", (1: 0.25rem, 2: 0.5rem)) using ($value)
        display: flex
        flex-direction: column
        gap: $value

.menu
    @extend %bf-stack-1
    @extend %bf-stack-2-md

.menu-named
    @extend %#{sassy.make-name("stack", 2)}
@layer sassy.base, sassy.sm, sassy.md, sassy.lg, sassy.xl, sassy.\32 xl, sassy.\33 xl;
@layer sassy.base {
  .menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  .menu-named {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
}
@layer sassy.md {
  @media (width >= 768px) {
    .menu {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }
  }
}
<div class="menu">
    <span class="box">One</span>
    <span class="box">Two</span>
    <span class="box">Three</span>
</div>
Docs: Mixins