Presets
Overview
The useUtilitiesPreset composable registers all available utility factories with your Styleframe instance in a single function call. It's essential when using recipes that need to auto-generate utility classes from CSS property values.
Why use presets?
- Recipe Integration: Enable recipes to automatically generate utility classes for any CSS property
- Complete Coverage: Register 200+ utility factories across all CSS property categories
- Zero Configuration: No setup required—just call the function and start building
- Optional Value Creation: Use returned creator functions to define specific utility values when needed
Quick Start
import { styleframe } from 'styleframe';
import { useUtilitiesPreset } from '@styleframe/theme';
const s = styleframe();
// Register all utility factories at once
const utilities = useUtilitiesPreset(s);
// Define a recipe - utilities auto-generate from property values
s.recipe({
name: 'button',
base: {
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
},
variants: {
size: {
sm: { padding: '0.5rem 1rem' },
md: { padding: '0.75rem 1.5rem' },
lg: { padding: '1rem 2rem' },
},
},
});
export default s;
/* Auto-generated utilities from recipe declarations */
._display\:inline-flex { display: inline-flex; }
._align-items\:center { align-items: center; }
._justify-content\:center { justify-content: center; }
._padding\:0\.5rem\ 1rem { padding: 0.5rem 1rem; }
._padding\:0\.75rem\ 1\.5rem { padding: 0.75rem 1.5rem; }
._padding\:1rem\ 2rem { padding: 1rem 2rem; }
/* Recipe classes */
.button { ... }
.button--size-sm { ... }
.button--size-md { ... }
.button--size-lg { ... }
useUtilitiesPreset
Registers all utility factories with the Styleframe instance and returns their creator functions. Supports configurable defaults with optional merge behavior.
Signature
function useUtilitiesPreset(
s: Styleframe,
config?: UtilitiesPresetConfig
): Record<string, UtilityCreator>
Configuration Options
Each utility category can be configured as:
- Omitted or
undefined(default): Use the preset's default values false: Skip this utility category entirelyRecord<string, string>: Use custom values- With
meta.merge: true: Merge custom values with defaults
ll configuration options accept false to disable the utility or Record<string, string> to provide custom values. Omitting an option uses the preset defaults.
Meta
| Option | Type | Description |
|---|---|---|
meta.merge | boolean | When true, custom values merge with defaults instead of replacing them |
Accessibility
| Option | CSS Property | Description |
|---|---|---|
forcedColorAdjust | forced-color-adjust | Forced color adjustment values |
Backgrounds
| Option | CSS Property | Description |
|---|---|---|
backgroundAttachment | background-attachment | Background attachment values (fixed, local, scroll) |
backgroundClip | background-clip | Background clipping values (border-box, padding-box, content-box, text) |
backgroundImage | background-image | Background image values (gradients, none) |
backgroundOrigin | background-origin | Background origin values (border-box, padding-box, content-box) |
backgroundPosition | background-position | Background position values (center, top, bottom, etc.) |
backgroundRepeat | background-repeat | Background repeat values (repeat, no-repeat, repeat-x, etc.) |
backgroundSize | background-size | Background size values (auto, cover, contain) |
Effects
| Option | CSS Property | Description |
|---|---|---|
backgroundBlendMode | background-blend-mode | Background blend mode values (normal, multiply, screen, etc.) |
mixBlendMode | mix-blend-mode | Mix blend mode values (normal, multiply, screen, etc.) |
Borders
| Option | CSS Property | Description |
|---|---|---|
divideStyle | border-style (children) | Divide style values (solid, dashed, dotted, etc.) |
outlineStyle | outline-style | Outline style values (none, solid, dashed, etc.) |
Flexbox & Grid
| Option | CSS Property | Description |
|---|---|---|
flex | flex | Flex shorthand values (1, auto, initial, none) |
flexDirection | flex-direction | Flex direction values (row, row-reverse, column, column-reverse) |
flexWrap | flex-wrap | Flex wrap values (wrap, wrap-reverse, nowrap) |
justifyContent | justify-content | Justify content values (start, end, center, between, around, evenly) |
justifyItems | justify-items | Justify items values (start, end, center, stretch) |
justifySelf | justify-self | Justify self values (auto, start, end, center, stretch) |
alignContent | align-content | Align content values (start, end, center, between, around, evenly) |
alignItems | align-items | Align items values (start, end, center, baseline, stretch) |
alignSelf | align-self | Align self values (auto, start, end, center, baseline, stretch) |
placeContent | place-content | Place content values (start, end, center, between, around, evenly) |
placeItems | place-items | Place items values (start, end, center, baseline, stretch) |
placeSelf | place-self | Place self values (auto, start, end, center, stretch) |
gridAutoFlow | grid-auto-flow | Grid auto flow values (row, column, dense, row-dense, column-dense) |
Interactivity
| Option | CSS Property | Description |
|---|---|---|
appearance | appearance | Appearance values (none, auto) |
colorScheme | color-scheme | Color scheme values (normal, light, dark) |
cursor | cursor | Cursor values (auto, pointer, wait, text, move, etc.) |
pointerEvents | pointer-events | Pointer events values (auto, none) |
resize | resize | Resize values (none, both, horizontal, vertical) |
scrollBehavior | scroll-behavior | Scroll behavior values (auto, smooth) |
scrollSnapAlign | scroll-snap-align | Scroll snap align values (start, end, center, none) |
scrollSnapStop | scroll-snap-stop | Scroll snap stop values (normal, always) |
scrollSnapType | scroll-snap-type | Scroll snap type values (none, x, y, both, mandatory, proximity) |
touchAction | touch-action | Touch action values (auto, none, manipulation, pan-x, pan-y, etc.) |
userSelect | user-select | User select values (auto, none, text, all) |
willChange | will-change | Will change values (auto, scroll-position, contents, transform) |
Layout
| Option | CSS Property | Description |
|---|---|---|
aspectRatio | aspect-ratio | Aspect ratio values (auto, square, video) |
boxDecorationBreak | box-decoration-break | Box decoration break values (clone, slice) |
boxSizing | box-sizing | Box sizing values (border-box, content-box) |
breakAfter | break-after | Break after values (auto, avoid, all, page, column, etc.) |
breakBefore | break-before | Break before values (auto, avoid, all, page, column, etc.) |
breakInside | break-inside | Break inside values (auto, avoid, avoid-page, avoid-column) |
clear | clear | Clear values (start, end, left, right, both, none) |
display | display | Display values (block, inline, flex, grid, none, etc.) |
float | float | Float values (start, end, left, right, none) |
isolation | isolation | Isolation values (isolate, auto) |
objectFit | object-fit | Object fit values (contain, cover, fill, none, scale-down) |
objectPosition | object-position | Object position values (center, top, bottom, left, right, etc.) |
overflow | overflow | Overflow values (auto, hidden, clip, visible, scroll) |
overscroll | overscroll-behavior | Overscroll values (auto, contain, none) |
position | position | Position values (static, fixed, absolute, relative, sticky) |
visibility | visibility | Visibility values (visible, invisible, collapse) |
Tables
| Option | CSS Property | Description |
|---|---|---|
borderCollapse | border-collapse | Border collapse values (collapse, separate) |
captionSide | caption-side | Caption side values (top, bottom) |
tableLayout | table-layout | Table layout values (auto, fixed) |
Transforms
| Option | CSS Property | Description |
|---|---|---|
backfaceVisibility | backface-visibility | Backface visibility values (visible, hidden) |
perspectiveOrigin | perspective-origin | Perspective origin values (center, top, bottom, left, right, etc.) |
transformOrigin | transform-origin | Transform origin values (center, top, bottom, left, right, etc.) |
transformStyle | transform-style | Transform style values (flat, preserve-3d) |
Transitions & Animation
| Option | CSS Property | Description |
|---|---|---|
animation | animation | Animation preset values (none, spin, ping, pulse, bounce) |
transitionBehavior | transition-behavior | Transition behavior values (normal, allow-discrete) |
transitionProperty | transition-property | Transition property values (none, all, colors, opacity, shadow, transform) |
Typography
| Option | CSS Property | Description |
|---|---|---|
fontSmoothing | -webkit-font-smoothing | Font smoothing values (antialiased, subpixel-antialiased) |
fontStretch | font-stretch | Font stretch values (ultra-condensed, condensed, normal, expanded, etc.) |
fontVariantNumeric | font-variant-numeric | Font variant numeric values (normal, ordinal, slashed-zero, etc.) |
hyphens | hyphens | Hyphenation values (none, manual, auto) |
listStylePosition | list-style-position | List style position values (inside, outside) |
listStyleType | list-style-type | List style type values (none, disc, decimal, etc.) |
overflowWrap | overflow-wrap | Overflow wrap values (normal, break-word) |
textAlign | text-align | Text alignment values (left, center, right, justify, start, end) |
textDecorationLine | text-decoration-line | Text decoration line values (none, underline, overline, line-through) |
textDecorationStyle | text-decoration-style | Text decoration style values (solid, double, dotted, dashed, wavy) |
textOverflow | text-overflow | Text overflow values (clip, ellipsis) |
textTransform | text-transform | Text transform values (none, uppercase, lowercase, capitalize) |
textWrap | text-wrap | Text wrap values (wrap, nowrap, balance, pretty) |
verticalAlign | vertical-align | Vertical alignment values (baseline, top, middle, bottom, etc.) |
whitespace | white-space | Whitespace values (normal, nowrap, pre, pre-line, pre-wrap, break-spaces) |
wordBreak | word-break | Word break values (normal, break-all, keep-all, break-word) |
Return Value
Returns an object containing creator functions for all registered utilities. Each creator function allows you to define specific values for that utility.
const {
createMarginUtility,
createPaddingUtility,
createDisplayUtility,
// ... 200+ more creators
} = useUtilitiesPreset(s);
Using Creator Functions
While recipes auto-generate utilities from property values, you can also use the returned creator functions to define specific utility values for direct use in your HTML:
import { styleframe } from 'styleframe';
import { useUtilitiesPreset, useSpacing } from '@styleframe/theme';
const s = styleframe();
// Create spacing tokens
const { spacingSm, spacingMd, spacingLg } = useSpacing(s, {
default: '@md',
sm: '0.5rem',
md: '1rem',
lg: '1.5rem',
});
// Register all utilities and get creators
const {
createMarginUtility,
createPaddingUtility,
createGapUtility,
} = useUtilitiesPreset(s);
// Define specific values using your design tokens
createMarginUtility({
sm: s.ref(spacingSm),
md: s.ref(spacingMd),
lg: s.ref(spacingLg),
auto: 'auto',
});
createPaddingUtility({
sm: s.ref(spacingSm),
md: s.ref(spacingMd),
lg: s.ref(spacingLg),
});
createGapUtility({
sm: s.ref(spacingSm),
md: s.ref(spacingMd),
lg: s.ref(spacingLg),
});
export default s;
This generates utility classes like _margin:sm, _padding:md, _gap:lg that reference your design tokens.
Available Utilities
The preset registers utility factories for all CSS property categories. Here's a complete breakdown:
Accessibility
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createForcedColorAdjustUtility | forced-color-adjust | _forced-color-adjust:* |
createSrOnlyUtility | (multiple) | _sr-only:* |
createNotSrOnlyUtility | (multiple) | _not-sr-only:* |
Backgrounds
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createBackgroundAttachmentUtility | background-attachment | _background-attachment:* |
createBackgroundClipUtility | background-clip | _background-clip:* |
createBackgroundColorUtility | background-color | _background-color:* |
createBackgroundImageUtility | background-image | _background-image:* |
createBackgroundUtility | background | _background:* |
createBackgroundOriginUtility | background-origin | _background-origin:* |
createBackgroundPositionUtility | background-position | _background-position:* |
createBackgroundRepeatUtility | background-repeat | _background-repeat:* |
createBackgroundSizeUtility | background-size | _background-size:* |
createGradientFromUtility | gradient-from | _gradient-from:* |
createGradientToUtility | gradient-to | _gradient-to:* |
createGradientViaUtility | gradient-via | _gradient-via:* |
Borders
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createBorderColorUtility | border-color | _border-color:* |
createBorderColorTopUtility | border-top-color | _border-top-color:* |
createBorderColorRightUtility | border-right-color | _border-right-color:* |
createBorderColorBottomUtility | border-bottom-color | _border-bottom-color:* |
createBorderColorLeftUtility | border-left-color | _border-left-color:* |
createBorderColorXUtility | border-left/right-color | _border-x-color:* |
createBorderColorYUtility | border-top/bottom-color | _border-y-color:* |
createBorderColorStartUtility | border-inline-start-color | _border-inline-start-color:* |
createBorderColorEndUtility | border-inline-end-color | _border-inline-end-color:* |
createBorderRadiusUtility | border-radius | _border-radius:* |
createBorderRadiusTopUtility | border-top-*-radius | _border-radius-top:* |
createBorderRadiusRightUtility | border-*-right-radius | _border-radius-right:* |
createBorderRadiusBottomUtility | border-bottom-*-radius | _border-radius-bottom:* |
createBorderRadiusLeftUtility | border-*-left-radius | _border-radius-left:* |
createBorderRadiusTopLeftUtility | border-top-left-radius | _border-radius-top-left:* |
createBorderRadiusTopRightUtility | border-top-right-radius | _border-radius-top-right:* |
createBorderRadiusBottomLeftUtility | border-bottom-left-radius | _border-radius-bottom-left:* |
createBorderRadiusBottomRightUtility | border-bottom-right-radius | _border-radius-bottom-right:* |
createBorderRadiusStartUtility | border-start-*-radius | _border-radius-start:* |
createBorderRadiusEndUtility | border-end-*-radius | _border-radius-end:* |
createBorderRadiusStartStartUtility | border-start-start-radius | _border-radius-start-start:* |
createBorderRadiusStartEndUtility | border-start-end-radius | _border-radius-start-end:* |
createBorderRadiusEndStartUtility | border-end-start-radius | _border-radius-end-start:* |
createBorderRadiusEndEndUtility | border-end-end-radius | _border-radius-end-end:* |
createBorderStyleUtility | border-style | _border-style:* |
createBorderWidthUtility | border-width | _border-width:* |
createBorderWidthTopUtility | border-top-width | _border-width-top:* |
createBorderWidthRightUtility | border-right-width | _border-width-right:* |
createBorderWidthBottomUtility | border-bottom-width | _border-width-bottom:* |
createBorderWidthLeftUtility | border-left-width | _border-width-left:* |
createBorderWidthXUtility | border-left/right-width | _border-width-x:* |
createBorderWidthYUtility | border-top/bottom-width | _border-width-y:* |
createBorderWidthStartUtility | border-inline-start-width | _border-width-start:* |
createBorderWidthEndUtility | border-inline-end-width | _border-width-end:* |
createDivideColorUtility | border-color (children) | _divide-color:* |
createDivideStyleUtility | border-style (children) | _divide-style:* |
createDivideXUtility | border-left-width | _divide-x:* |
createDivideXReverseUtility | divide-x-reverse | _divide-x-reverse:* |
createDivideYUtility | border-top-width | _divide-y:* |
createDivideYReverseUtility | divide-y-reverse | _divide-y-reverse:* |
createOutlineColorUtility | outline-color | _outline-color:* |
createOutlineOffsetUtility | outline-offset | _outline-offset:* |
createOutlineStyleUtility | outline-style | _outline-style:* |
createOutlineWidthUtility | outline-width | _outline-width:* |
createRingColorUtility | ring-color | _ring-color:* |
createRingInsetUtility | ring-inset | _ring-inset:* |
createRingOffsetColorUtility | ring-offset-color | _ring-offset-color:* |
createRingOffsetWidthUtility | ring-offset-width | _ring-offset-width:* |
createRingWidthUtility | box-shadow (ring) | _ring-width:* |
Effects
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createBackgroundBlendModeUtility | background-blend-mode | _background-blend-mode:* |
createBoxShadowUtility | box-shadow | _box-shadow:* |
createBoxShadowColorUtility | box-shadow-color | _box-shadow-color:* |
createMixBlendModeUtility | mix-blend-mode | _mix-blend-mode:* |
createOpacityUtility | opacity | _opacity:* |
createTextShadowUtility | text-shadow | _text-shadow:* |
createTextShadowColorUtility | text-shadow-color | _text-shadow-color:* |
Filters
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createBackdropBlurUtility | backdrop-filter: blur() | _backdrop-blur:* |
createBackdropBrightnessUtility | backdrop-filter: brightness() | _backdrop-brightness:* |
createBackdropContrastUtility | backdrop-filter: contrast() | _backdrop-contrast:* |
createBackdropGrayscaleUtility | backdrop-filter: grayscale() | _backdrop-grayscale:* |
createBackdropHueRotateUtility | backdrop-filter: hue-rotate() | _backdrop-hue-rotate:* |
createBackdropInvertUtility | backdrop-filter: invert() | _backdrop-invert:* |
createBackdropOpacityUtility | backdrop-filter: opacity() | _backdrop-opacity:* |
createBackdropSaturateUtility | backdrop-filter: saturate() | _backdrop-saturate:* |
createBackdropSepiaUtility | backdrop-filter: sepia() | _backdrop-sepia:* |
createBlurUtility | filter: blur() | _blur:* |
createBrightnessUtility | filter: brightness() | _brightness:* |
createContrastUtility | filter: contrast() | _contrast:* |
createDropShadowUtility | filter: drop-shadow() | _drop-shadow:* |
createGrayscaleUtility | filter: grayscale() | _grayscale:* |
createHueRotateUtility | filter: hue-rotate() | _hue-rotate:* |
createInvertUtility | filter: invert() | _invert:* |
createSaturateUtility | filter: saturate() | _saturate:* |
createSepiaUtility | filter: sepia() | _sepia:* |
Flexbox & Grid
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createAlignContentUtility | align-content | _align-content:* |
createAlignItemsUtility | align-items | _align-items:* |
createAlignSelfUtility | align-self | _align-self:* |
createFlexUtility | flex | _flex:* |
createFlexBasisUtility | flex-basis | _flex-basis:* |
createFlexDirectionUtility | flex-direction | _flex-direction:* |
createFlexGrowUtility | flex-grow | _flex-grow:* |
createFlexShrinkUtility | flex-shrink | _flex-shrink:* |
createFlexWrapUtility | flex-wrap | _flex-wrap:* |
createGapUtility | gap | _gap:* |
createGapXUtility | column-gap | _gap-x:* |
createGapYUtility | row-gap | _gap-y:* |
createGridAutoColumnsUtility | grid-auto-columns | _grid-auto-columns:* |
createGridAutoFlowUtility | grid-auto-flow | _grid-auto-flow:* |
createGridAutoRowsUtility | grid-auto-rows | _grid-auto-rows:* |
createGridColumnUtility | grid-column | _grid-column:* |
createGridColumnEndUtility | grid-column-end | _grid-column-end:* |
createGridColumnStartUtility | grid-column-start | _grid-column-start:* |
createGridRowUtility | grid-row | _grid-row:* |
createGridRowEndUtility | grid-row-end | _grid-row-end:* |
createGridRowStartUtility | grid-row-start | _grid-row-start:* |
createGridTemplateColumnsUtility | grid-template-columns | _grid-template-columns:* |
createGridTemplateRowsUtility | grid-template-rows | _grid-template-rows:* |
createJustifyContentUtility | justify-content | _justify-content:* |
createJustifyItemsUtility | justify-items | _justify-items:* |
createJustifySelfUtility | justify-self | _justify-self:* |
createOrderUtility | order | _order:* |
createPlaceContentUtility | place-content | _place-content:* |
createPlaceItemsUtility | place-items | _place-items:* |
createPlaceSelfUtility | place-self | _place-self:* |
Interactivity
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createAccentColorUtility | accent-color | _accent-color:* |
createAppearanceUtility | appearance | _appearance:* |
createCaretColorUtility | caret-color | _caret-color:* |
createColorSchemeUtility | color-scheme | _color-scheme:* |
createCursorUtility | cursor | _cursor:* |
createPointerEventsUtility | pointer-events | _pointer-events:* |
createResizeUtility | resize | _resize:* |
createScrollBehaviorUtility | scroll-behavior | _scroll-behavior:* |
createScrollMarginUtility | scroll-margin | _scroll-margin:* |
createScrollMarginTopUtility | scroll-margin-top | _scroll-margin-top:* |
createScrollMarginRightUtility | scroll-margin-right | _scroll-margin-right:* |
createScrollMarginBottomUtility | scroll-margin-bottom | _scroll-margin-bottom:* |
createScrollMarginLeftUtility | scroll-margin-left | _scroll-margin-left:* |
createScrollMarginXUtility | scroll-margin-left/right | _scroll-margin-x:* |
createScrollMarginYUtility | scroll-margin-top/bottom | _scroll-margin-y:* |
createScrollMarginStartUtility | scroll-margin-inline-start | _scroll-margin-start:* |
createScrollMarginEndUtility | scroll-margin-inline-end | _scroll-margin-end:* |
createScrollPaddingUtility | scroll-padding | _scroll-padding:* |
createScrollPaddingTopUtility | scroll-padding-top | _scroll-padding-top:* |
createScrollPaddingRightUtility | scroll-padding-right | _scroll-padding-right:* |
createScrollPaddingBottomUtility | scroll-padding-bottom | _scroll-padding-bottom:* |
createScrollPaddingLeftUtility | scroll-padding-left | _scroll-padding-left:* |
createScrollPaddingXUtility | scroll-padding-left/right | _scroll-padding-x:* |
createScrollPaddingYUtility | scroll-padding-top/bottom | _scroll-padding-y:* |
createScrollPaddingStartUtility | scroll-padding-inline-start | _scroll-padding-start:* |
createScrollPaddingEndUtility | scroll-padding-inline-end | _scroll-padding-end:* |
createScrollSnapAlignUtility | scroll-snap-align | _scroll-snap-align:* |
createScrollSnapStopUtility | scroll-snap-stop | _scroll-snap-stop:* |
createScrollSnapTypeUtility | scroll-snap-type | _scroll-snap-type:* |
createTouchActionUtility | touch-action | _touch-action:* |
createUserSelectUtility | user-select | _user-select:* |
createWillChangeUtility | will-change | _will-change:* |
Layout
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createAspectRatioUtility | aspect-ratio | _aspect-ratio:* |
createBottomUtility | bottom | _bottom:* |
createBoxDecorationBreakUtility | box-decoration-break | _box-decoration-break:* |
createBoxSizingUtility | box-sizing | _box-sizing:* |
createBreakAfterUtility | break-after | _break-after:* |
createBreakBeforeUtility | break-before | _break-before:* |
createBreakInsideUtility | break-inside | _break-inside:* |
createClearUtility | clear | _clear:* |
createColumnsUtility | columns | _columns:* |
createDisplayUtility | display | _display:* |
createFloatUtility | float | _float:* |
createInsetUtility | inset | _inset:* |
createInsetXUtility | left + right | _inset-x:* |
createInsetYUtility | top + bottom | _inset-y:* |
createInsetStartUtility | inset-inline-start | _inset-start:* |
createInsetEndUtility | inset-inline-end | _inset-end:* |
createIsolationUtility | isolation | _isolation:* |
createLeftUtility | left | _left:* |
createObjectFitUtility | object-fit | _object-fit:* |
createObjectPositionUtility | object-position | _object-position:* |
createOverflowUtility | overflow | _overflow:* |
createOverflowXUtility | overflow-x | _overflow-x:* |
createOverflowYUtility | overflow-y | _overflow-y:* |
createOverscrollUtility | overscroll-behavior | _overscroll:* |
createOverscrollXUtility | overscroll-behavior-x | _overscroll-x:* |
createOverscrollYUtility | overscroll-behavior-y | _overscroll-y:* |
createPositionUtility | position | _position:* |
createRightUtility | right | _right:* |
createTopUtility | top | _top:* |
createVisibilityUtility | visibility | _visibility:* |
createZIndexUtility | z-index | _z-index:* |
Sizing
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createHeightUtility | height | _height:* |
createMaxHeightUtility | max-height | _max-height:* |
createMaxWidthUtility | max-width | _max-width:* |
createMinHeightUtility | min-height | _min-height:* |
createMinWidthUtility | min-width | _min-width:* |
createSizeUtility | width + height | _size:* |
createWidthUtility | width | _width:* |
Spacing
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createMarginUtility | margin | _margin:* |
createMarginTopUtility | margin-top | _margin-top:* |
createMarginRightUtility | margin-right | _margin-right:* |
createMarginBottomUtility | margin-bottom | _margin-bottom:* |
createMarginLeftUtility | margin-left | _margin-left:* |
createMarginXUtility | margin-left + margin-right | _margin-x:* |
createMarginYUtility | margin-top + margin-bottom | _margin-y:* |
createMarginInlineUtility | margin-inline | _margin-inline:* |
createMarginInlineStartUtility | margin-inline-start | _margin-inline-start:* |
createMarginInlineEndUtility | margin-inline-end | _margin-inline-end:* |
createMarginBlockUtility | margin-block | _margin-block:* |
createPaddingUtility | padding | _padding:* |
createPaddingTopUtility | padding-top | _padding-top:* |
createPaddingRightUtility | padding-right | _padding-right:* |
createPaddingBottomUtility | padding-bottom | _padding-bottom:* |
createPaddingLeftUtility | padding-left | _padding-left:* |
createPaddingXUtility | padding-left + padding-right | _padding-x:* |
createPaddingYUtility | padding-top + padding-bottom | _padding-y:* |
createPaddingInlineUtility | padding-inline | _padding-inline:* |
createPaddingInlineStartUtility | padding-inline-start | _padding-inline-start:* |
createPaddingInlineEndUtility | padding-inline-end | _padding-inline-end:* |
createPaddingBlockUtility | padding-block | _padding-block:* |
createSpaceXUtility | margin-left (children) | _space-x:* |
createSpaceXReverseUtility | space-x-reverse | _space-x-reverse:* |
createSpaceYUtility | margin-top (children) | _space-y:* |
createSpaceYReverseUtility | space-y-reverse | _space-y-reverse:* |
SVG
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createFillUtility | fill | _fill:* |
createStrokeUtility | stroke | _stroke:* |
createStrokeWidthUtility | stroke-width | _stroke-width:* |
Tables
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createBorderCollapseUtility | border-collapse | _border-collapse:* |
createBorderSpacingUtility | border-spacing | _border-spacing:* |
createBorderSpacingXUtility | border-spacing (horizontal) | _border-spacing-x:* |
createBorderSpacingYUtility | border-spacing (vertical) | _border-spacing-y:* |
createCaptionSideUtility | caption-side | _caption-side:* |
createTableLayoutUtility | table-layout | _table-layout:* |
Transforms
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createBackfaceVisibilityUtility | backface-visibility | _backface-visibility:* |
createPerspectiveUtility | perspective | _perspective:* |
createPerspectiveOriginUtility | perspective-origin | _perspective-origin:* |
createRotateUtility | rotate | _rotate:* |
createRotateXUtility | rotate-x | _rotate-x:* |
createRotateYUtility | rotate-y | _rotate-y:* |
createScaleUtility | scale | _scale:* |
createScaleXUtility | scale-x | _scale-x:* |
createScaleYUtility | scale-y | _scale-y:* |
createSkewXUtility | skew-x | _skew-x:* |
createSkewYUtility | skew-y | _skew-y:* |
createTransformOriginUtility | transform-origin | _transform-origin:* |
createTransformStyleUtility | transform-style | _transform-style:* |
createTranslateUtility | translate | _translate:* |
createTranslateXUtility | translate-x | _translate-x:* |
createTranslateYUtility | translate-y | _translate-y:* |
createTranslateZUtility | translate-z | _translate-z:* |
Transitions & Animation
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createAnimationUtility | animation | _animation:* |
createTransitionBehaviorUtility | transition-behavior | _transition-behavior:* |
createTransitionDelayUtility | transition-delay | _transition-delay:* |
createTransitionDurationUtility | transition-duration | _transition-duration:* |
createTransitionPropertyUtility | transition-property | _transition-property:* |
createTransitionTimingFunctionUtility | transition-timing-function | _transition-timing-function:* |
Typography
| Creator Function | CSS Property | Class Pattern |
|---|---|---|
createColorUtility | color | _color:* |
createContentUtility | content | _content:* |
createFontFamilyUtility | font-family | _font-family:* |
createFontSizeUtility | font-size | _font-size:* |
createFontSmoothingUtility | -webkit-font-smoothing | _font-smoothing:* |
createFontStretchUtility | font-stretch | _font-stretch:* |
createFontStyleUtility | font-style | _font-style:* |
createFontVariantNumericUtility | font-variant-numeric | _font-variant-numeric:* |
createFontWeightUtility | font-weight | _font-weight:* |
createHyphensUtility | hyphens | _hyphens:* |
createLetterSpacingUtility | letter-spacing | _letter-spacing:* |
createLineClampUtility | -webkit-line-clamp | _line-clamp:* |
createLineHeightUtility | line-height | _line-height:* |
createListStyleImageUtility | list-style-image | _list-style-image:* |
createListStylePositionUtility | list-style-position | _list-style-position:* |
createListStyleTypeUtility | list-style-type | _list-style-type:* |
createOverflowWrapUtility | overflow-wrap | _overflow-wrap:* |
createTextAlignUtility | text-align | _text-align:* |
createTextColorUtility | color | _text-color:* |
createTextDecorationColorUtility | text-decoration-color | _text-decoration-color:* |
createTextDecorationLineUtility | text-decoration-line | _text-decoration-line:* |
createTextDecorationStyleUtility | text-decoration-style | _text-decoration-style:* |
createTextDecorationThicknessUtility | text-decoration-thickness | _text-decoration-thickness:* |
createTextIndentUtility | text-indent | _text-indent:* |
createTextOverflowUtility | text-overflow | _text-overflow:* |
createTextTransformUtility | text-transform | _text-transform:* |
createTextUnderlineOffsetUtility | text-underline-offset | _text-underline-offset:* |
createTextWrapUtility | text-wrap | _text-wrap:* |
createVerticalAlignUtility | vertical-align | _vertical-align:* |
createWhitespaceUtility | white-space | _whitespace:* |
createWordBreakUtility | word-break | _word-break:* |
Examples
Full Recipe Integration
import { styleframe } from 'styleframe';
import { useDesignTokensPreset, useUtilitiesPreset } from '@styleframe/theme';
const s = styleframe();
// Set up design tokens
const { colors, spacing, borderRadius } = useDesignTokensPreset(s);
// Register all utilities for recipe auto-generation
useUtilitiesPreset(s);
// Define a card recipe - utilities auto-generate
s.recipe({
name: 'card',
base: {
display: 'flex',
flexDirection: 'column',
backgroundColor: s.ref(colors.colorLight),
borderRadius: s.ref(borderRadius.borderRadiusMd),
overflow: 'hidden',
},
variants: {
padding: {
none: { padding: '0' },
sm: { padding: s.ref(spacing.spacingSm) },
md: { padding: s.ref(spacing.spacingMd) },
lg: { padding: s.ref(spacing.spacingLg) },
},
shadow: {
none: { boxShadow: 'none' },
sm: { boxShadow: '0 1px 2px 0 rgb(0 0 0 / 0.05)' },
md: { boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1)' },
},
},
defaultVariants: {
padding: 'md',
shadow: 'sm',
},
});
export default s;
Selective Utility Creation
If you only need specific utilities with custom values, use the creator functions:
import { styleframe } from 'styleframe';
import { useUtilitiesPreset, useSpacing, useColor } from '@styleframe/theme';
const s = styleframe();
// Create design tokens
const { spacingSm, spacingMd, spacingLg, spacingXl } = useSpacing(s, {
default: '@md',
sm: '0.5rem',
md: '1rem',
lg: '1.5rem',
xl: '2rem',
});
const { colorPrimary, colorSecondary } = useColor(s, {
primary: '#3b82f6',
secondary: '#6b7280',
});
// Get specific creators
const {
createMarginUtility,
createPaddingUtility,
createBackgroundColorUtility,
createTextColorUtility,
} = useUtilitiesPreset(s);
// Create utilities with your design tokens
createMarginUtility({
sm: s.ref(spacingSm),
md: s.ref(spacingMd),
lg: s.ref(spacingLg),
xl: s.ref(spacingXl),
auto: 'auto',
});
createPaddingUtility({
sm: s.ref(spacingSm),
md: s.ref(spacingMd),
lg: s.ref(spacingLg),
xl: s.ref(spacingXl),
});
createBackgroundColorUtility({
primary: s.ref(colorPrimary),
secondary: s.ref(colorSecondary),
white: '#ffffff',
transparent: 'transparent',
});
createTextColorUtility({
primary: s.ref(colorPrimary),
secondary: s.ref(colorSecondary),
white: '#ffffff',
black: '#000000',
});
export default s;
Combining with Design Tokens Preset
import { styleframe } from 'styleframe';
import { useDesignTokensPreset, useUtilitiesPreset } from '@styleframe/theme';
const s = styleframe();
// Create comprehensive design tokens
const tokens = useDesignTokensPreset(s);
// Register all utilities
const utilities = useUtilitiesPreset(s);
// Use token values for utilities
utilities.createMarginUtility({
'2xs': s.ref(tokens.spacing.spacing2xs),
xs: s.ref(tokens.spacing.spacingXs),
sm: s.ref(tokens.spacing.spacingSm),
md: s.ref(tokens.spacing.spacingMd),
lg: s.ref(tokens.spacing.spacingLg),
xl: s.ref(tokens.spacing.spacingXl),
'2xl': s.ref(tokens.spacing.spacing2xl),
auto: 'auto',
});
utilities.createBorderRadiusUtility({
none: s.ref(tokens.borderRadius.borderRadiusNone),
sm: s.ref(tokens.borderRadius.borderRadiusSm),
md: s.ref(tokens.borderRadius.borderRadiusMd),
lg: s.ref(tokens.borderRadius.borderRadiusLg),
full: s.ref(tokens.borderRadius.borderRadiusFull),
});
export default s;
Custom Configuration
Customize specific utility categories while using defaults for others:
import { styleframe } from 'styleframe';
import { useUtilitiesPreset } from '@styleframe/theme';
const s = styleframe();
const utilities = useUtilitiesPreset(s, {
// Use custom display values
display: {
block: 'block',
flex: 'flex',
grid: 'grid',
hidden: 'none',
},
// Disable position utilities entirely
position: false,
// Custom cursor values
cursor: {
auto: 'auto',
pointer: 'pointer',
grab: 'grab',
},
// All other utilities use their defaults
});
export default s;
Merging with Defaults
Add custom values while keeping all defaults:
import { styleframe } from 'styleframe';
import { useUtilitiesPreset } from '@styleframe/theme';
const s = styleframe();
const utilities = useUtilitiesPreset(s, {
meta: { merge: true },
// These values are ADDED to the defaults, not replacing them
cursor: {
'custom-cursor': "url('custom.cur'), auto",
},
display: {
'custom-display': 'contents',
},
});
// Now you have all default cursor values PLUS 'custom-cursor'
// And all default display values PLUS 'custom-display'
export default s;
Best Practices
- Use with recipes: Call
useUtilitiesPreset()before defining recipes to enable auto-generation - Leverage design tokens: Use
ref()to reference design token variables in utility values - Be selective: Only call creator functions for utilities you need direct HTML access to
- Combine presets: Use alongside
useDesignTokensPreset()for a complete system - Keep it DRY: Let recipes auto-generate utilities instead of manually defining duplicate values
FAQ
useUtilitiesPreset(s) registers all utility factories. Recipes will automatically generate utility classes for any CSS property values used in base, variants, and compoundVariants. Creator functions are optional—use them only when you want to define specific utility values for direct HTML use.useMarginUtility) must be imported and called separately. useUtilitiesPreset() registers all 200+ utility factories in one call, making it ideal for recipe-based workflows. Use individual composables when you only need a few specific utilities and want to minimize bundle size.Yes! The preset registers factory functions—it doesn't create any utility values until you either call the creator functions or use recipes. You can mix and match:
const utilities = useUtilitiesPreset(s);
// Use preset creator
utilities.createMarginUtility({ sm: '0.5rem', md: '1rem' });
// Also use individual composable for more control
import { usePaddingUtility } from '@styleframe/theme';
usePaddingUtility(s, { sm: '0.5rem', md: '1rem' }, [hoverModifier]);
No—registering utilities doesn't generate any CSS. CSS is only generated when:
- You call a creator function with values
- A recipe uses a CSS property that matches a registered utility
This means you get comprehensive coverage without bloat.
When using creator functions, you can pass modifiers as the second argument:
const hover = s.modifier('hover', ({ declarations }) => ({
'&:hover': declarations,
}));
const { createOpacityUtility } = useUtilitiesPreset(s);
createOpacityUtility({ 0: '0', 50: '0.5', 100: '1' }, [hover]);
// Generates: _opacity:50, _hover:opacity:50, etc.
Pass a configuration object as the second argument. You can:
- Replace defaults by providing a custom record
- Disable utilities by setting them to
false - Merge with defaults using
meta.merge: true
const utilities = useUtilitiesPreset(s, {
meta: { merge: true }, // Add to defaults instead of replacing
display: { custom: 'contents' }, // Added to default display values
position: false, // Disable position utilities
cursor: { pointer: 'pointer' }, // Replace all cursor defaults
});