CSS Properties Reference Guide
A quick reference of all custom properties used in SmolCSS patterns.
Container
--smol-container-padding: 1.5rem--smol-container-max-width: 60ch
Grid
--smol-grid-min-item-width: 15ch--smol-grid-gap: 1rem
Flexbox Grid
--smol-flex-min-item-width: 10ch--smol-flex-gap: 1rem
Columns
--smol-columns-count: 2--smol-columns-width: 15ch--smol-columns-gap: 1rem
Switcher
--smol-switcher-threshold: 30rem--smol-switcher-gap: 1rem--smol-switcher-space: 0
Stack
--smol-stack-gap: 1rem--smol-stack-recursive-gap: 0.5rem
Box
--smol-box-padding: 1rem--smol-box-border-radius: 0.25rem--smol-box-border-width: 1px--smol-box-border-color: #ddd
Center
--smol-center-padding: 1rem--smol-center-max-width: 60ch--smol-center-text-align: left
Sidebar
--smol-sidebar-gap: 1rem--smol-sidebar-min-content-width: 50%--smol-sidebar-sidebar-width: 20ch
Cluster
--smol-cluster-gap: 1rem--smol-cluster-justify: flex-start--smol-cluster-align: center
Frame
--smol-frame-height: auto--smol-frame-width: 100%--smol-frame-aspect-ratio: 16/9
Breakout
--smol-breakout-max-width: (60ch + 40vw)
Flow
--smol-flow-spacing: 1em
Cover
--smol-cover-min-height: 100vh--smol-cover-padding: 1rem--smol-cover-gap: 1rem
1. Responsive Container
A centered container with responsive padding that maxes out at a comfortable reading width.
CSS Properties
-
--smol-container-padding: Space on the sides (1.5rem) -
--smol-container-max-width: Maximum width (60ch)
This works by using the min() function with two values:
- Full width minus padding (100% - padding*2)
- Max width (var(--smol-container-max-width))
I'm a responsive container that's centered with padding and a max-width.
2. Auto Grid
A responsive grid layout that automatically adjusts the number of columns based on available space.
CSS Properties
-
--smol-grid-min-item-width: Minimum width for each item (15ch) -
--smol-grid-gap: Space between grid items (1rem)
This works by using CSS Grid with auto-fit and minmax():
-
Items will be at least
--smol-grid-min-item-widthwide -
Items will not overflow the container thanks to the
min()function -
Items will stretch to fill available space with
1fr
3. Flexbox Grid
A flexible grid layout using flexbox that allows items to grow and wrap naturally.
CSS Properties
-
--smol-flex-min-item-width: Base size for flex items (10ch) -
--smol-flex-gap: Space between flex items (1rem)
This works through flexbox:
-
Flex items use
flex: 1 1 var(--smol-flex-min-item-width) - Items grow and shrink, but try to maintain their base width
- Items wrap when they don't fit on a line
4. Multi-column Layout
A layout that automatically divides content into multiple columns for better readability.
CSS Properties
--smol-columns-count: Number of columns (2)-
--smol-columns-width: Minimum column width (15ch) -
--smol-columns-gap: Space between columns (1rem)
This uses CSS Multi-column Layout:
- By default uses a fixed column count
- With feature detection, switches to a more flexible width-based approach
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eget enim vel nisi commodo lacinia. Proin volutpat, velit eu pharetra pellentesque, nisi sem convallis magna, at facilisis eros nulla id purus.
Suspendisse sed odio quis nulla pretium convallis. Fusce ut ex eget orci fermentum lacinia. Vivamus ac fringilla ex, ac pharetra tellus. Sed quis sagittis lorem.
Curabitur rhoncus, quam id tempus faucibus, felis urna efficitur justo, at mattis sapien eros in nisl. Nam luctus diam eu felis lacinia, quis tristique elit elementum.
Donec pharetra ultrices purus, vel interdum nibh interdum quis. Integer pretium eu ligula sed volutpat. Nullam sit amet placerat leo, quis porttitor nulla.
5. Switcher
A layout that switches between horizontal and vertical arrangement based on available space.
CSS Properties
-
--smol-switcher-threshold: Width at which layout switches (30rem) -
--smol-switcher-gap: Space between items (1rem)
This works through a clever flexbox technique:
-
Uses
flex-basis: calc((var(--smol-switcher-threshold) - 100%) * 999) - When container width is less than the threshold, items stack vertically
- When container width exceeds the threshold, items arrange horizontally
- The additional rule ensures more than two items always stack
6. Stack
A simple vertical stack with consistent spacing between elements.
CSS Properties
-
--smol-stack-gap: Space between direct children (1rem) -
--smol-stack-recursive-gap: Space between all nested children (0.5rem) when using recursive variant
This works by:
- Using flexbox with
flex-direction: column -
Setting margins between elements using the adjacent sibling selector
* + * - Offering a recursive variant that applies spacing to all descendants
7. Box
A simple bordered container with padding.
CSS Properties
--smol-box-padding: Internal padding (1rem)-
--smol-box-border-radius: Corner radius (0.25rem) -
--smol-box-border-width: Border thickness (1px) --smol-box-border-color: Border color (#ddd)
This is a simple component that applies consistent styling to create a box container.
I'm content inside a box component with consistent padding and border styling.
8. Center
A component for horizontally centering content with a maximum width.
CSS Properties
-
--smol-center-max-width: Maximum content width (60ch) -
--smol-center-padding: Horizontal padding (1rem) -
--smol-center-text-align: Text alignment (left)
This works by:
-
Using
margin-inline: autoto center the container -
Setting
box-sizing: content-boxto handle padding correctly - Limiting width with
max-width
This content is centered horizontally with a maximum width for optimal readability.
10. Cluster
A flexible layout for grouping related items with consistent spacing.
CSS Properties
--smol-cluster-gap: Space between items (1rem)-
--smol-cluster-justify: Horizontal alignment (flex-start) -
--smol-cluster-align: Vertical alignment (center)
This uses flexbox with wrapping:
- Items are laid out in a row with consistent spacing
- Items wrap to new lines when needed
- Alignment can be customized
11. Frame
A responsive container that maintains a specific aspect ratio for media.
CSS Properties
-
--smol-frame-aspect-ratio: Width to height ratio (16/9) --smol-frame-width: Width of the media (100%)-
--smol-frame-height: Height of the media (auto)
This works by:
-
Using the
aspect-ratioproperty to maintain proportions - Centering the content with flexbox
-
Using
object-fit: coverfor media to fill the space
12. Breakout
A component that breaks out of the content flow to span the full viewport width.
CSS Properties
-
--smol-breakout-max-width: Maximum width for the breakout (--smol-max-width + 40vw)
This works through creative positioning:
- Uses
width: 100vwto span the full viewport -
Centers with
margin-left: 50%andtransform: translateX(-50%) - Caps the maximum width to prevent excessive stretching
Normal width content above
I break out of the container and span the full viewport width!
Normal width content below
13. Flow
A simple utility for adding consistent vertical spacing between elements.
CSS Properties
-
--smol-flow-spacing: Space between flow items (1em)
This works by:
-
Using the adjacent sibling selector
* + *to add top margin - Only applying spacing between elements, not before the first or after the last
First paragraph in the flow.
Second paragraph with consistent spacing above.
Third paragraph with the same spacing.
- A list item in the flow
- Another list item
Final paragraph with consistent spacing.
14. Cover
A layout that covers the full viewport height with centered content.
CSS Properties
-
--smol-cover-min-height: Minimum height (100vh) --smol-cover-padding: Internal padding (1rem)-
--smol-cover-gap: Space between elements (1rem)
This works by:
- Setting
min-height: 100vhto cover the viewport - Using flexbox with column direction
-
Items with class
.smol-cover-centeredwill center vertically - First and last elements align to the top and bottom (unless centered)