@@ -112,7 +113,8 @@ When colorizing buttons, remember to set their `hover:` hover state shades too.
-Link “button”
+
+Link “button”
```
## Buttons with icons
@@ -157,55 +159,40 @@ The `r-pill` class on a square icon button will make it circular. (See [decorati
```
-
+
-
+
```
## Button sizes
Buttons (and the `btn` utility) will resize according to the font-size of the block that they are inside.
-You can also use the typographic size classes `t-small` and `t-big` to modify buttons directly.
+You can also use the typographic size classes `t-sm` and `t-lg` to modify buttons directly.
```
```
-Button x-axis padding is `1em`, so that it will also respond to the text size of the button.
-
-## Stretch buttons
-
-You can increase the x-axis padding (using the responsive `px-2` or `px-3`) to make a button more impressive:
+Notes on buttons:
-
-
-```
-
-
-
-
-
-```
+1. Button x-axis padding is `1em`, so that it will also respond to the text size of the button.
+2. Buttons have the same min-height as form input fields, so that they can be used in combination.
diff --git a/_src/colors.md b/_src/colors.md
index c37766c..d922dbb 100644
--- a/_src/colors.md
+++ b/_src/colors.md
@@ -9,167 +9,183 @@ nextLink: "Forms"
---
-
- Since March 2023, all “evergreen” browsers (Chrome, Edge, Firefox, Safari) have capability for the new color-mix() function (see Can I use). Baselayer 3.3.x uses this function to set up a range of shades for its built-in (example) colors.
+
+ Since March 2023, all “evergreen” browsers (Chrome, Edge, Firefox, Safari) have capability for the new color-mix() function (see Can I use). Baselayer uses this function to set up a range of shades for its built-in (example) colors.
-Example using background `bg-*` utility classes:
-
-
-
-
bg-blue
-
bg-100
-
bg-200
-
bg-300
-
bg-400
-
bg-500
-
bg-600
-
bg-700
-
bg-800
-
bg-900
+## Rationale for Baselayer’s color system
+
+I wanted to develop a color system based on interpolating CSS variables for generating a series _lightness levels_ for each color, so that the stylesheet doesn’t need to be loaded with lighness classes for every color — most of which you’d never use.
+
+After experimenting with variables in _lightness channels_ within color codes, I discovered the new (mid-2023) [color-mix function](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix). Using `color-mix()` has proved to be better suited to what I was trying to do. With it we can build a series of lightness levels by mixing in white (tints) or black (shades).
+
+For repeatability in Baselayer CSS, starting color swatches need to have a mid-range lightness level, but they can be specified using any system. Currently, Baselayer default colors are set using Hex `#` codes. And the color-mix function now outputs colors in [OKLCH](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch) using `color-mix(in OKLCH ...)` because I this gives perceptually uniform lightness levels.
+
+The color utility CSS class names remain the same as before (explained below). Example using background `bg-*` utility classes:
+
+
+
+
blue
+
100
+
200
+
300
+
400
+
500
+
600
+
700
+
800
+
900
-
-
bg-green
-
bg-100
-
bg-200
-
bg-300
-
bg-400
-
bg-500
-
bg-600
-
bg-700
-
bg-800
-
bg-900
+
+
green
+
100
+
200
+
300
+
400
+
500
+
600
+
700
+
800
+
900
-
-
bg-amber
-
bg-100
-
bg-200
-
bg-300
-
bg-400
-
bg-500
-
bg-600
-
bg-700
-
bg-800
-
bg-900
+
+
amber
+
100
+
200
+
300
+
400
+
500
+
600
+
700
+
800
+
900
-
-
bg-red
-
bg-100
-
bg-200
-
bg-300
-
bg-400
-
bg-500
-
bg-600
-
bg-700
-
bg-800
-
bg-900
+
+
red
+
100
+
200
+
300
+
400
+
500
+
600
+
700
+
800
+
900
-
-
bg-gray
-
bg-100
-
bg-200
-
bg-300
-
bg-400
-
bg-500
-
bg-600
-
bg-700
-
bg-800
-
bg-900
+
+
gray
+
100
+
200
+
300
+
400
+
500
+
600
+
700
+
800
+
900
-## Rationale for Baselayer’s color system
-
-I wanted to develop a color system that was based on CSS variables for generating a series of shades for each color, so that the stylesheet didn’t need to be overloaded with all the shade permutations for each color — most of which you would never use.
-
-Previously, I experimented with setting **shades based on lightness channels**, first in the `hsl` (Baselayer 3.1.x) and later in the new `oklch` color systems (Baselayer 3.2.x). This was successful, but it involved the additional effort of converting colors to OKLCH and to separate out their color channels into different variables, for enabling them to work with the shade channel utilities.
+Also available:
-In Baselayer 3.3, I have switched to setting **shades based on mixing in white or black** using the new `color-mix()` function (see [MDN docs: color-mix()](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix)). The CSS classes remain the same as before, while the color format is now hex (#) based. This is easier to maintain, and stylesheet is smaller.
+1. A built-in [dark theme](#dark-theme).
+2. Black, white, and transparent — see [other Baselayer color utilities](#other-baselayer-color-utilities).
## Color and shade utility classes
-All colors and shades are declared in `variables.css`.
-
-Color utility classes (declared in `@layer color-setup`) are prefixed acording to where the color will be applied:
-
-* Border color:
- * `b-*`
- * `hover:b-*` — border color on hover
-* Text color:
- * `t-*`
- * `hover:t-*` — text color on hover
-* Background color:
- * `bg-*`
- * `hover:bg-*` — background color on hover
+All colors and lightness levels are declared in `variables.css`.
-I have named the colors according to their common names (blue, green, amber, red, gray), instead of opting to name them according to the common user interface (UI) “success”, “warning”, “danger” etc. — so that you can make color utilities or components with colors dedicated to those purposes, meanwhile allowing you to adjust these built-in named colors and also add your own.
+Color utility classes (declared in `@layer color` in `colors.css`) are prefixed acording to where the color will be applied — border `b-*` text `t-*` or background `bg-*`. I have named the colors according to their common names (blue, green, amber, red, gray). You can modify the root variables of these colors, and you can [add your own colors](#adding-more-colors).
-All color utilities “start” at their `*-500` level, or mid-tone (this is what you will get if you don’t add a shade modifier utility).
-
-The shade modifier utilities (declared in `@layer color-shade`) are as follows:
-
-* Border:
- * `b-100` through `b-900`
- * `hover:b-100` through `hover:b-900`
-* Text:
- * `t-100` through `t-900`
- * `hover:t-100` through `hover:t-900`
-* Background:
- * `bg-100` through `bg-900`
- * `hover:bg-100` through `hover:bg-900`
-
-Also available:
-
-1. [Dark theme](#dark-theme), via the `theme-dark` wrapper — see .
-2. `b-dark-invert`, `t-dark-invert`, and `bg-dark-invert` modifiers that invert the shade for dark mode, in those situations when you want light elements in light mode to become dark elements in dark mode (and _vise versa_) — see [darker and inverted shade utilities](#darker-and-inverted-shade-utilities).
-3. Black, white, reversi, and transparent — see [other Baselayer color utilities](#other-baselayer-color-utilities).
+
+
+
+
+
+
Border Color
+
Text Color
+
Background Color
+
+
+
Default state
+
Hover state
+
Default state
+
Hover state
+
Default state
+
Hover state
+
+
+
+
+
Base color class
+
b-*
+
hover:b-*
+
t-*
+
hover:t-*
+
bg-*
+
hover:bg-*
+
+
+
Lightness modifier
+
b-100 ... b-900
+
hover:b-100 ... hover:b-900
+
t-100 ... t-900
+
hover:t-100 ... hover:t-900
+
bg-100 ... bg-900
+
hover:bg-100 ... hover:bg-900
+
+
+
+
Example border, text and background utilities:
-
-
b-green
-
t-greent-600t-dark-invert
-
bg-greenbg-200
+
+
b-green
+
t-greent-600t-dark-invert
+
bg-greenbg-200
+See also [inverting lightness levels for the dark theme](#inverting-lightness-levels-for-the-dark-theme)
+
```
-
+
```
Example usage:
-
- ⚠ Warning alert panel.
+
+ ☆ Note (information) panel.
```html
-
- ⚠ Warning alert panel.
+
+ ☆ Note (information) panel.
```
-The shades `*-100` through `*-900`, if used alone, don’t provide color. But if you use them to supplement one of the other colors above, then that color class will provide the color, and the shade class will set its lightness level.
+The lighness modifiers `*-100` through `*-900`, if used alone, do not provide color. But if you use them to supplement one of the base colors above, then that color class will provide the color, and the modifier will set its lightness level.
## Colors and accessibility
-
+
In any color model, color combinations must be chosen with care so that there is sufficient contrast between text and background colors for purposes of assessibility.
-In your text and background color combinations, be careful to ensure that the text is readable — there needs to be an adequate contrast. Generally, you will want to aim at **WCAG level AA** for accessibility compliance.
+In your text and background color combinations, be careful to ensure that the text is readable — there needs to be an adequate contrast. Most organizations should to aim for [WCAG level AA](https://www.w3.org/WAI/WCAG2AA-Conformance) for accessibility requirements.
-For WCAG level AA compliance, most user interface colors need to be _darker than the middle shade_ (i.e. use `*-600` up) if the text color is white, or _lighter than the middle shade_ (i.e. use `*-400` down) if the text color is black.
+For WCAG level AA conformance, most user interface colors need to be _darker than the mid-level_ (i.e. use `*-600` up) if the text color is white, or _lighter than the mid-level_ (i.e. use `*-400` down) if the text color is black.
-However, any colors near yellow, such as Baselayer amber, as well as orange and yellow-green (not included) are notoriously difficult for accessibility. You may do better using a lighter background amber and pairing it with black text.
+However, any colors near yellow such as Baselayer amber, as well as orange and yellow-green (not included), are especially difficult for accessibility. You may do better using a lighter background amber and pairing it with black text (or vise versa).
-
@@ -183,10 +199,10 @@ When colorizing buttons, remember to set their `hover:` hover state shades too.
-
+
-
+
```
Background reading on colors and accessibility:
@@ -200,68 +216,127 @@ Background reading on colors and accessibility:
* The [_Coolors_ contrast checker](https://coolors.co/contrast-checker/112a46-acc8e5)
* [Web Accessibility: Understanding Colors and Luminance (Mozilla Developer Network Docs)](https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance)
-## Adding more colors and shades
+## Adding more colors
You can, of course, add any colors you want, and in any format you want.
-However, if you want to use Baselayer 3.3.x’s shade classes `-100` thorugh `-900` on your color(s), then you need to start from a mid-tone that works as a `-500` shade. The `color-mix()` formulas mix in various levels of white to shades `-100` through `-400`, and various levels of black to shades `-600` through `-900`.
+However, if you want to use Baselayer’s lightness modifier classes `-100` thorugh `-900` on your colors, then you need to start from a _mid-lightness_ color so that the `-100` and the `-900` generated by the `color-mix()` formulas are distinguishable (not to chose to white or too close to black).
-Also, you will need to put your color(s) in `@layer color-setup {}` so that it gets added before `@layer color-shades {}`.
+Also, you will need to put your color(s) in CSS layer `@layer colors {}` so that they take precence over the Baselayer lightness modifiers and other color utilities.
-You can add your own project colors in any format, but the Baselayer `color-mix()` formulas will output shade in SRGB format.
+You can add your own project colors in any format, but the Baselayer `color-mix()` formulas will output shade in OKLCH format.
+
+Examples:
+
+```css
+:root {
+ --purple: #9400d3;
+ --teal: #0080A2;
+}
+
+@layer colors {
+ .bg-purple,
+ .hover\:bg-purple:hover {
+ --bgc: var(--purple);
+ background: var(--bgc);
+ }
+ .bg-teal,
+ .hover\:bg-teal:hover {
+ --bgc: var(--teal);
+ background: var(--bgc);
+ }
+}
+```
## Dark theme
-Baselayer 3 has a simple dark theme built in. The dark theme is as follows:
+Baselayer has a simple dark theme built in. Since v.3.4.0, the user’s operating system preference for light or dark mode is automatically detected on the HTML tag:
-1. HTML elements are generally flipped from light to dark, or dark to light:
- * Body background is near black
- * Text is near white
- * Table borders, horizontal rules, form inputs are dark gray
- * Text links are a lighter blue
- * Default buttons are a lighter gray
-2. Color utilities (blue, green, amber, red, gray) are slightly darkened, to make them easier on the eye.
-3. On hover, the link text color and the default button background color both are made lighter (inverted behavior).
-4. Color utilities can optionally be inverted by adding the `*-dark-invert` modifier classes.
+```css
+html {
+ color-scheme: light dark;
+}
+```
-### The `theme-dark` class
+For the dark theme, HTML elements are generally flipped from light to dark, or dark to light, as required:
-In `baselayer.min.css` the dark theme is set by the CSS class `theme-dark` that can be programatically added to the `` tag by a [JavaScript toggle](#dark%2Flight-theme-toggle).
+* Body background is near black
+* Text is near white
+* Table borders, horizontal rules, form inputs are dark gray
+* Text links are a lighter blue
+* Default buttons are a lighter gray
-If you don’t want to give your visitors the option to toggle, then you can manually refactor the CSS to make the dark theme simply respond to the `prefers-color-scheme: dark` instead.
+All the theme color variables in Baselayer (since v.3.4.0) involve a `light-dark()` CSS function. For example:
```css
-@media (prefers-color-scheme: dark) {
+:root {
/*
- Your dark theme styles
+ Body tag background color
*/
+ --bgc-body: light-dark(
+ white,
+ color-mix(in OKLCH, var(--gray), var(--l1000))
+ );
+
+ /*
+ Base text color (also set on the body tag)
+ */
+ --tc-base: light-dark(
+ color-mix(in OKLCH, var(--gray), var(--l900)),
+ color-mix(in OKLCH, var(--gray), var(--l100))
+ );
+}
+```
+
+Baselayer does not use `@media (prefers-color-scheme: dark) {}` anywhere.
+
+The color shade utilities can [optionally be inverted](#inverting-lightness-levels-for-the-dark-theme) by adding the `*-dark-invert` modifier classes.
+
+### Light and dark theme classes
+
+If you wish to give your visitors the option to switch between light and dark modes, you can include a JavaScript that swaps between CSS classes `theme-light` and `theme-dark` on the HTML tag. Baselayer has these two tags built in, so that you can implement the style selection:
+
+```css
+html {
+ color-scheme: light dark;
+ &.theme-light {
+ color-scheme: light;
+ }
+ &.theme-dark {
+ color-scheme: dark;
+ }
}
```
-### Darker and inverted shade utilities
+Example implementation: the Baselayer documentation has demo JavaScript switches for light, dark, and auto modes. The auto mode removes `theme-light` and `theme-dark` from the `` tag, so that you simply get the Baselayer default, that is the user’s operating system theme preference setting.
+
+### Inverting lightness levels for the dark theme
-Each color shade variant has a darker shade for the dark theme. For example, in dark mode `bg-100` is slightly darker than in light mode. This makes the shades easier on the eye in dark mode.
+There will be many situations in your design where you want your utility color shades flipped for the dark theme, same way as the background color is flipped from white to near black, and son on. For handling this, Baselayer has three optional `*-dark-invert` modifier classes that flip the lightness modifier utility values.
-There are, however, circumstances in your design where you don’t want colors to be merely darkened but also inverted (light shades become dark shades, and dark shades become light shades).
+```css
+/* Border lightness inverter */
+.b-dark-invert
-This shade inverting has been built into the dark theme for (classless) `` background, text, links, form inputs, table borders, and horizontal rules.
+/* Text lightness inverter */
+.t-dark-invert
-Baselayer 3 has an optinal inverted version of of its shade utilities (for text, border, and background), as well as having them shoghtly darkened. To make this happen, all you need to do is add another modifier class to those elements you wish to shade invert for dark mode.
+/* Background lightness inverter */
+.bg-dark-invert
+```
Example using `bg-blue`:
```html
-
-
```
-
+
-
Shade (lightness)
+
Shade
bg-blue
bg-blue bg-dark-invert
@@ -315,173 +390,69 @@ Example using `bg-blue`:
-The middle `t-500`, `b-500`, and `bg-500` do not invert, of course. So, e.g. `bg-500 bg-dark-invert` does not exist in `baselayer.css`.
+(The middle `t-500`, `b-500`, and `bg-500` do not invert.)
-
Baselayer 3.3.x’s color shades are darkened for the dark theme
-
-
-
-
-### Hover states for links and buttons
-
-In the default light theme, the blue link text becomes a darker blue, and the default gray button becomes a darker gray, on `:hover` states. But in the dark theme, this behaviour is inverted: links become a lighter blue and buttons become a lighter gray.
+### Dark theme HTML body background color
-You can easily change this. Lighter and darker options for blue links and gray buttons are included in variables as follows:
+For dark teme, Baselayer’s `` background color has been set by `color-mix(in OKLCH, var(--gray), var(--l1000)`. This darkest shade level `--l1000` (near black) is only used on the `` tag, and it has been set so that all Baselayer `bg-900` shades will still be seen by many people.
-```css
-.theme-dark {
- /* text color for links (default) */
- --tc-link: color-mix(in srgb, var(--blue) calc(var(--l400) * 2), white);
- --tc-link-lighter: color-mix(in srgb, var(--blue) calc(var(--l300) * 2), white);
- --tc-link-darker: color-mix(in srgb, var(--blue) calc(var(--l500) * 2), white);
- --tc-link-hover: var(--tc-link-lighter);
-
- /* background color for buttons (default) */
- --bgc-btn: color-mix(in srgb, var(--gray) calc((100% - var(--l600)) * 2), black);
- --bgc-btn-lighter: color-mix(in srgb, var(--gray) calc((100% - var(--l500)) * 2), white);
- --bgc-btn-darker: color-mix(in srgb, var(--gray) calc((100% - var(--l700)) * 2), black);
- --bgc-btn-hover: var(--bgc-btn-lighter);
-}
-```
+
+
+
+
+
+
+
-To make your styled links and buttons have an inverted behavior as above, you need to use `*-dark-invert` utilities.
+### What if you don’t want a dark theme?
-### Dark theme HTML body background color
-
-Baselayer 3’s dark theme `` color has been made darker than the color shades set by the `bg-900` utility, so that elements colored by those shades are still visible. For this purpose an shade variable of `--l1000` has been added. (Therefore, you can use `bg-900` or `bg-100 bg-dark-invert` to color the background of a panel, without it “disappearing” into the body background color.)
+Then you can simply override or replace the HTML tag as follows:
```css
-.theme-dark {
- --l1000: 87.5%;
-
- --bgc-body: color-mix(in srgb, var(--gray) calc((100% - var(--l1000)) * 2), black); /* = #1e1e1e */
+html {
+ color-scheme: light;
}
```
-As with all Baselayer’s variables, this dark theme `` color is an example that you can change to suit the needs of your project.
+(And you won’t need to use any `*-dark-invert` classes.)
-### Dark/light theme toggle
-
-Baselayer’s dark/light theme switcher JavaScript uses [sessionStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) in the user’s browser to remember their theme preference as they visit multiple pages in this documentation.
-
-This script adds the CSS class `theme-dark` to the `` tag of the webpage, so that it is implimented (almost) immediately, before the `` is painted in the browser window.
-
-The switcher script also adds `theme-light` to the `` tag in light mode, but there are no `theme-light` classes in `baselayer.min.css`. The `theme-light` class is merely there for visual confirmation to the deleveloper viewing the browser inspector, and it is used for adjusting the dark/light theme state indicator symbol in the switcher button.
-
-The theme switcher in the Baselayer docs is built into its `switcher.js` demo toggling system, that powers the buttons in the sidebar. If you want to use the same dark/light mode toggler, here it is isolated below (no JS framework required):
-
-```js
-const matchMediaDark = window.matchMedia('(prefers-color-scheme: dark)');
-const htmlClassList = document.querySelector('html').classList;
-
-function themeDark() {
- sessionStorage.setItem("baselayerTheme", "dark");
- htmlClassList.remove('theme-light');
- htmlClassList.add('theme-dark');
-}
-
-function themeLight() {
- sessionStorage.setItem("baselayerTheme", "light");
- htmlClassList.remove('theme-dark');
- htmlClassList.add('theme-light');
-}
-
-function toggleTheme() {
- if ( sessionStorage.baselayerTheme === 'dark' ) {
- themeLight();
- } else {
- themeDark();
- }
-};
-
-function baselayerInit() {
- if (sessionStorage.baselayerTheme === 'dark' || (!('baselayerTheme' in sessionStorage) && matchMediaDark.matches)) {
- themeDark();
- } else {
- themeLight();
- }
-};
+## Other Baselayer color utilities
-baselayerInit();
-```
+
+ The color utilities for black, white, and transparent can’t be used on the same element with the colors and shades above (i.e. as either default or hover states). These other utilities are declared after the colors and shades, and so they will override them.
+
-You will also need a toggle button, like the one in the sidebar. The checkmarks are added in by CSS pseudo-selectors.
-
-
-
-
-
-Another, simpler example theme toggle button, using glyphs selected from [&what;](https://www.amp-what.com)
-
-
-
-
-
-
+Other color utilities included in Baselayer cover black, white, and transparent.
-```
-
-
-
-```
+### Black and white
-The simple example above uses `bg-reversi` to put a “night time” black background behind the moon and a “day time” white background behind the sun, meanwhile `t-reversi-` flips the text color the opposite way. See [black, white, reversi, and reversi-alt](/baselayer-3/colors/#black%2C-white%2C-reversi%2C-and-reversi-alt) below.
+* `*-black` — named color black
+* `*-white` — named color white
-## Other Baselayer color utilities
-
-
- The color utilities for black, white, reversi, reversi-alt, and transparent can’t be used on the same element with the colors and shades above (i.e. as either default or hover states). These other utilities are declared after the colors and shades, and so they will override them.
+
+
t-white bg-black
+
t-black bg-white
-Other color utilities included in Baselayer cover black, white, and transparent, as follows:
-
-### Black, white, reversi, and reversi-alt
+#### Inverting black and white for the dark theme
-There are utilities for border color, text color, and background color for each of the following (and `hover:` prefix states):
+**New in Baselayer v.3.4.0:** The `*-dark-invert` classes also work on the black and white utilities, enabling a [reversi](https://en.wikipedia.org/wiki/Reversi) effect when the user prefers the dark theme.
-* `-black` — named color black:
-* `-white` — named color white:
-* `-reversi` is black on a light theme, white on a dark theme:
-* `-reversi-alt` is white on a light theme, black on a dark theme:
-
-
+Both margin and padding spacers are controlled on the 4 sides of blocks, as follows:
-
p-3
+* All: `m-0` through `m-4` / `p-0` through `p-4` (all four sides)
+* Top: `mt-0` through `mt-4` / `pt-0` through `pt-4`
+* Right: `mr-0` through `mr-4` / `pr-0` through `pr-4`
+* Bottom: `mb-0` through `mb-4` / `pb-0` through `pb-4`
+* Left: `ml-0` through `ml-4` / `pl-0` through `pl-4`
+* Inline axis, or x-axis (right and left): `mx-1` through `mx-4` / `px-4` through `px-4`
+* Block axis, or y-axis (top and bottom): `my-1` through `my-4` / `py-4` through `py-4`
-
p-4
+The zero `*-0` options (top, roght, bottom, or left) are for removing (resetting) unwanted margin and padding.
### Spacing extras
In addition, there are the following specials:
-* `p-cell` — adds y-axis padding `--sp-1` and x-axis padding of double `--sp-1` for creating menu items. Same as the padding for table cells and buttons
-* `mx-auto` — for x-axis margin auto-centering
-* `m-0`, `mt-0`, `mb-0`, and `p-0` — for removing (resetting) unwanted space.
-
-`mb-0` is commonly used for removing the bottom margin on the last paragraph (or other typographic block) inside a `
` panel. `mt-0` is commonly used for removing top margin for headers used in side-columns (e.g. for navigation menus).
-
-These zero spacing utilities are declared before the spacers above in `decoration.css` so that you can use them to _reset_ and then use spacers to set spacing the way you want it.
+* `p-cell` — adds y-axis padding `--s-1` and x-axis padding of double `--s-1` for creating menu items. Same as the padding for table cells and buttons
+* `mx-auto` — for x-axis margin auto-centering
## Borders
Baselayer provides three thicknesses of border (plus a zero border override):
-
b-1 (1px)
-
-
b-2 (4px)
-
-
b-3 (8px)
+
+
b-thin (1px)
+
b-thick (4px)
+
b-heavy (8px)
+
Borders can be set as follows:
@@ -95,61 +126,49 @@ Borders can be set as follows:
## Rounded corners
-* `r-2` — 4px border radius
-* `r-3` — 8px border radius
-* `r-4` — 16px border radius
+All Baselayer border radius classes apply their border radius _potentially to all four corners_. If you want different radii on different corners of the same element, then you can access each of the spacing variables in your CSS, or set your own values.
-
-
r-2
-
r-3
-
r-4
-
+**Tip:** If you are putting rounded corners on a block element that contains an image, you will also need to add `overflow-clip`.
-**Note:** border-radius classes have `overflow: hidden` built in, so that they can “clip” the corners of images.
-
-Border and border-radius variables pair as follows:
-
-
-
-
-
Border variable
-
Border-radius variable
-
Value
-
-
-
-
-
--b1
-
n/a
-
1px
-
-
-
--b2
-
--r2
-
4px
-
-
-
--b3
-
--r3
-
8px
-
-
-
n/a
-
--r4
-
16px
-
-
-
+The first five border radius classes below supply the property `border-{...}-radius` and the default spacing variable `--s-1` (0.5rem).
+
+* `rad`, `rad-1` — `border-radius:` (all) `--s-1` (0.5rem)
+* `rad-tl` — `border-top-left-radius: `--s-1`
+* `rad-tr` — `border-top-right-radius: `--s-1`
+* `rad-br` — `border-bottom-right-radius: `--s-1`
+* `rad-bl` — `border-bottom-left-radius: `--s-1`
-**Note:** There is no `--r1` (a border radius of 1px) or `--b4` (border radius of 16px) in Baselayer.
+Then there are five modifier classes. These only supply a spacing variable — they do not contain the `border-{...}-radius` property. Therefore, they need to be paired with (at least) one of the five border radius utilities above.
-* `r-pill` — 99em border radius (more than sufficient to put x-axis semi-circular ends on even mid-sized blocks)
+* `rad-xs` — `--s-xs` 0.25rem
+* `rad-2` — `--s-2` clamp(1rem, 0.5rem + 1.25cqi, 1.5rem)
+* `rad-3` — `--s-3` clamp(2rem, 1rem + 2.5cqi, 3rem)
+* `rad-4` — `--s-4` clamp(3rem, 1.5rem + 3.75cqi, 4.5rem)
+* `rad-pill` — `--s-pill` 99rem
-
pill
+Examples:
+
+
+
rad rad-xs
+
rad or rad-1
+
rad rad-2
+
rad rad-3
+
rad rad-4
+
rad rad-pill
+
rad-tl rad-br rad-3
+
rad-tl rad-bl rad-pill
+
rad-tr rad-pill
+
+
+If the element is a square, then `rad rad-pill` makes a circle.
+
+
+
rad rad-pill
+
-If `r-pill` is used on a square, then the result will be a circle.
+### Rounded corners extra
-
280px² square pill
+* `unrounded` — in some sutuations (e.g. if you code-in rounded corners on form elements and buttons), you may need to remove rounded corners with `unrounded`.
## The `img-cover` class
@@ -180,4 +199,4 @@ The hover states are provided in case you want an image inside a link to change
If you use these on an image over a colored background, then you get a color-tinted image.
-If you have text over an image (e.g. in a hero component), then you can use opacity over a black (or dark color) background to make white text more readable — and _vise versa_.
\ No newline at end of file
+If you have text over an image (e.g. in a hero component), then you can use opacity over a black (or dark color) background to make white text more readable — and _vise versa_.
diff --git a/_src/examples.md b/_src/examples.md
index f9ec855..e79307b 100644
--- a/_src/examples.md
+++ b/_src/examples.md
@@ -4,236 +4,174 @@ mainHeading: Examples
layout: base-fw.njk
---
-
-
-
+## [Centered layout wrappers]({{ "/layout/#centered-layout-wrappers" | url }})
-## Labels (see [decoration](/baselayer-3/decoration/))
+**Note:** `container` is simply used for adding a [container query context]({{ "/layout/#container-query-contexts" | url }}) — it doesn’t add any constraints.
+
+
A malleable grid without equalization set. on the cell widths. In this example, for sm up, columns will adopt whatever width they require for their content. CSS grid requires column placement classes to know where you want your columns, so that it can figure out how many columns you need.
+## Up to four column [grid layouts]({{ "/layout/#grid" | url }})
+
+A malleable grid without setting equalization on cell widths. In this example, for sm up, columns will adopt whatever width they require for their content. Specify where you want your _grid items_ using column placement classes — then _CSS grid_ will figure out how many columns you need.
+
+
grid gap-1
-
-
sm:col-1 A narrow column
-
sm:col-2 This will be a wide column because it has a lot of content. This will be a wide column because it has a lot of content. This will be a wide column because it has a lot of content.
-
sm:col-3 Another narrow column
-
+
sm:col-1 A narrow column
+
sm:col-2 This will be a wide column because it has a lot of content. This will be a wide column because it has a lot of content. This will be a wide column because it has a lot of content.
+
sm:col-3 Another narrow column
-
+Using `equal-` modifiers on the grid wrapper will both equalize column width and specify the number of columns. Then for simple layouts (e.g. galleries), you won’t need column placement classes.
+
+
grid sm:equal-2-cols gap-2
-
-
#
-
#
+
+
#
+
#
grid sm:equal-2-cols md:equal-3-cols gap-2
-
-
#
-
#
-
#
-
#
-
sm:col-span-2
+
+
#
+
#
+
#
+
#
+
sm:col-span-2
-grid sm:equal-4-cols gap-2
-
-
#
-
#
-
sm:col-span-2
-
sm:col-span-3
-
#
+
sm:grid takes effect at 640px up. Below 640px, gap-2 will have no effect.
+sm:grid sm:equal-4-cols gap-2
+
+
#
+
sm:col-span-2
+
sm:col-span-3
+
sm:col-4 sm:row-1 sm:row-span-2
-## Example components
-
-
-
-
-
- ☆ Information panel
-
-
- ⚠ Warning alert panel.
-
-
-
-
-
Card category
-
-
-
-
-
Card title
-
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum.
-
-## Example components using [grid](/baselayer-3/layout/#grid)
+* * *
-
-
-
-
-
-
-
-
-
-
Media object
-
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum.
-
-
-
-
-
+## Text sizes
-
-
-
-
-
-
-
-
-
-
-
-
Media object
-
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum.
-
-
-
-
-
-
+See [typography]({{ "/typography/" | url }}). `t-lg` simply enlarges by 1.325em. `t-long-read` and `t-display` involve a `clamp()`.
-
-
-
-
-
-
-
-
-
A “two-up” feature block
-
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum.
Paragraph. Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
+
+
+
Heading 1
+
Heading 2
+
Heading 3
+
Heading 4
+
Heading 5
+
Heading 6
+
Paragraph. Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
+
+
+
Heading 1
+
Heading 2
+
Heading 3
+
Heading 4
+
Heading 5
+
Heading 6
+
Paragraph. Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
+
+
+
Heading 1
+
Heading 2
+
Heading 3
+
Heading 4
+
Heading 5
+
Heading 6
+
Paragraph. Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
+
+
+
+
-## Research article page layout using [grid](/baselayer-3/layout/#grid)
+## Example “research article” page layout using [grid](/baselayer-3/layout/#grid)
-
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
+
Materials and Methods
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
Discussion
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
@@ -250,7 +190,7 @@ Back
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
+
content-grid is intended for long-form articles. Its 7-column grid places the content in column 4, where each immediate-child elment will be its own grid item. popout spans rows 3-5. expand spans rows 2-6. full-bleed spans rows 1-7.
Here’s a styled <p class="popout">:
-
+
☆ Information panel
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
Here’s a styled <div class="expand">:
-
-
This is a lot of example text that may or may not distort the aspect ratio (16×9) of this expand component.
-
See what it does on a small viewport width (e.g. phone).
+
+
This example text may or may not distort the 16×9 aspect ratio that has been given to this demo component.
+
The SVG image rectangle will be 1280px by 720px if your viewport is big enough. See what it does on a narrow viewport width (e.g. phone).
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
@@ -285,4 +227,116 @@ Back
full-bleed — expands to the full width of the avilable space. If there are no sidebars, it will reach the sides of the viewport.
-
\ No newline at end of file
+
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum. Natus debitis quisquam, expedita accusantium quos cumque?
+
+
+* * *
+
+## Example components
+
+Styled by utility classes.
+
+
+
+
+
Without *-dark-invert
+
+ ☆ Information panel
+
+
+ ⚠ Warning alert panel.
+
+
With *-dark-invert
+
+ ☆ Information panel
+
+
+ ⚠ Warning alert panel.
+
+
+
+
+
Card category
+
+
+
+
+
Card title
+
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magni rem animi quaerat accusantium illum architecto, nemo, ex harum voluptatum adipisci eum blanditiis dolorum.
In this example, the media object “collapses” to a single column below container width 640px, using sm:flex. And below that width, the title and button are centered using t-center, which is overridden by sm:t-left.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Grid media object
+
This example will behave as a grid for all container widths, even down to phones in portrait orientation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
A “two-up” feature block
+
In this exmple, the image is before the text content in the HTML. But for container width above 768px, the grid system places the image to the right (in the 2nd column). The text content is positioned vertical-center by flex flex-column flex-center
diff --git a/_src/forms.md b/_src/forms.md
index 735487a..9f16526 100644
--- a/_src/forms.md
+++ b/_src/forms.md
@@ -8,15 +8,16 @@ prevLink: "Colors"
nextLink: "Buttons"
---
-Baselayer form elements have simple background and focus styling (no default border).
+Baselayer form elements have simple background and focus styling.
**Notes:**
1. In Baselayer, form elements do not have set width. You can control widths them by one of two ways (same as for [buttons]({{ '/buttons/' | url }})):
* By adding the `w-100%` utility class to the form element, or
* By involving the form elements as immediate children of [flex layout]({{ '/layout/' | url }}#flex-layouts) or [grid layout]({{ '/layout/' | url }}#grid-layouts) wrappers.
+2. Form inputs (exclusing buttons) and textareas have a 1px solid border colored by `:root { --b-form: var(--tc-base); }`, so that the border will be the same as the default text color (near black on light theme, bear white on dark theme). This border color makes forms stand out more obvious as an interactive element.
2. Form inputs, textareas, buttons, and the `btn` class, have `font-size: inherit`. This means their font sizes can be modified by any font-size class in Baselayer.
-3. The font-family of form elements, buttons, and `btn` is controlled by `var(--base)` (default is sans-serif).
+3. The font-family of form elements, buttons, and `btn` is controlled by `var(--ff-base)` (default is sans-serif).
## Textual form input fields
@@ -128,6 +129,19 @@ On some devices (e.g. iOS Safari), these inputs get modified by number pickers (
+## List and datalist
+
+
+
+
+
+
## Text area (multiline)
```
-See [buttons](/baselayer-3/buttons) for more information.
\ No newline at end of file
+See [buttons](/baselayer-3/buttons) for more information.
diff --git a/_src/index.md b/_src/index.md
index 6dee524..c900f84 100644
--- a/_src/index.md
+++ b/_src/index.md
@@ -1,6 +1,6 @@
---
-title: Baselayer 3
-mainHeading: Baselayer 3 is a powerful, modern, tiny CSS library
+title: Getting started
+mainHeading: Getting started with Baselayer
layout: base.njk
nextPage: "/typography/"
nextLink: "Typography"
@@ -8,19 +8,19 @@ nextLink: "Typography"
## Introduction
-
Designed as a good place to start, Baselayer may be all you need — for small static websites and blogs. Or you may use it as a baselayer to quick-start your mega project.
+
Designed as a good place to start, Baselayer may be all you need for small projects such as static websites and blogs. Or you may use it as a baselayer to quick-start your mega project.
-Ready to use as-is, Baselayer 3’s {{ metadata.filesize }} (minified) stylesheet gives you all this:
+Ready to use as-is, Baselayer’s {{ metadata.filesize }} (minified) stylesheet gives you all this:
* A modern CSS reset
-* Foundational accessibility features
-* A lightweight system of utility classes for controlling dimensions, positioning, spacing, borders, text, images, and colors
-* Container-responsive typography and spacing
-* **Since v.3.2.0:** Container query responsive layouts using grid and flexbox
-* Styled form elements and buttons
-* **Since v.3.3.0:** A `color-mix()` based shade scale system of utilities for text, borders, and backgrounds
-* Built-in dark mode
-* Control of many of these things using CSS variables (a.k.a. custom properties)
+* Minimalist styled classless typographic, and form elements
+* Foundational accessibility features: outline based focus fings and a `visually-hidden` class
+* A lightweight system of utility classes for controlling dimensions, positioning, flexbox, spacing, borders, text, images, and colors
+* Container query responsive layouts using CSS grid
+* Responsive typography and spacing (margins, paddings, gaps) clases controlled by `clamp()`
+* A `color-mix(in OKLCH)` based shade scale system for utilities for text, borders, and backgrounds
+* Built-in dark mode using `light-dark()`
+* Control of many of these things using CSS `var()` (custom properties)
* And more
## Using several modern CSS technologies
@@ -31,19 +31,20 @@ Such as:
* [Grid](https://caniuse.com/css-grid)
* [Math functions (e.g. clamp)](https://caniuse.com/?search=css%20math%20functions)
* [Custom properties (variables)](https://caniuse.com/css-variables)
-* [Cascade layers](https://caniuse.com/css-cascade-layers)
* [color-mix() function](https://caniuse.com/?search=color-mix())
+* [light-dark() function](https://caniuse.com/mdn-css_types_color_light-dark)
+* [CSS class nesting](https://caniuse.com/css-nesting)
+* [Cascade layers](https://caniuse.com/css-cascade-layers)
-Therefore Baselayer supports only up-to-date (mid-2023 forward) “evergreen” web browsers (Safari, Firefox, Chrome, Edge, etc.).
-
-## Baselayer’s design philosophy
+Baselayer supports only up-to-date (2023 forward) [baseline compatibility](https://developer.mozilla.org/en-US/docs/Glossary/Baseline/Compatibility) web browsers (Safari, Firefox, Chrome, Edge, etc.).
+
+## Baselayer’s design philosophy
The design philosophy behind the Baselayer CSS project is as follows:
* Aim at being a good place to start — a _baselayer_ for a web design project.
-* Being so small ({{ metadata.filesize }}), there’s less you need to overwrite in order to style it your own way (and most things in Baselayer can be restyles by CSS variables ). So, there’s no need for a purge process to remove a heavy payload of unused Baselayer styles.
+* Being so small ({{ metadata.filesize }}), there’s less you need to overwrite in order to style it your own way (and most things in Baselayer can be restyles by CSS variables). So, there’s no need for a purge process to remove a heavy payload of unused Baselayer styles.
* PostCSS only — no need for Sass, Less, Stylus etc.
-* Plus, if you include the whole of `baselayer.min.css` along with your styles in a content management system (CMS), then you will still have it all available when you need to style simple components in the content editor.
## Built using PostCSS
@@ -54,23 +55,31 @@ Baselayer is built using [PostCSS](https://postcss.org) and some plugins. The pl
**Note:** neither [postcss-preset-env](https://preset-env.cssdb.org) nor [autoprefixer](https://github.com/postcss/autoprefixer) have been used in Baselayer. And preprocessors such as Sass are not required.
-## Modern CSS reset
+## A modern CSS reset
The Baselayer reset is a “best of both” combination of [Josh W Comeau’s custom CSS reset](https://www.joshwcomeau.com/css/custom-css-reset/) and [Andy Bell’s (more) modern CSS reset”](https://andy-bell.co.uk/a-more-modern-css-reset/).
From that basis, Baselayer then takes care of the basics by setting some minimalist, easy-to-read typography, and styles for buttons and forms.
-## Basic accessibility features
+## Baselayer’s built-in accessibility features
Baselayer has two “must have” accessibility features built-in.
-### (1.) Focus rings
+### (1.) Focus states
+
+After experimenting and testing various focus state styles, I have decided to base Baselayer’s on the ones in the design systems of the UK National Health Service [NHS.uk design system](https://design-system.service.gov.uk/get-started/focus-states/) and the UK Government [GOV.UK design system](https://design-system.service.gov.uk/get-started/focus-states/).
-**(a.) Form focus ring:**
+1. Links receive an amber background, black text and a thick black underline on `:focus-visible` — so that the element is clearly visible in a wide range of contexts.
-For form inputs and buttons on `:focus`, there’s a 4px light blue ring (see [colors](/colors)). Example:
+2. Interacive elements such as form inputs, form buttons*, collapsible details, and elements with overflowing content[^1] have what looks like a yellow and black “double border” that appears on `:focus` (actually its created by an outline and a box shadow).
-