Utilities

Utilities Presets

Quickly register all utility factories with the useUtilitiesPreset composable for seamless recipe integration and comprehensive utility class generation.

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

styleframe.config.ts
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;

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 entirely
  • Record<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

OptionTypeDescription
meta.mergebooleanWhen true, custom values merge with defaults instead of replacing them

Custom Names

Override the CSS class prefix for any utility by providing a names map. Keys are the default utility names (kebab-case), values are the replacement names.

OptionTypeDescription
namesRecord<string, string>Map of default utility names to custom names
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useUtilitiesPreset } from '@styleframe/theme';

const s = styleframe();

const utilities = useUtilitiesPreset(s, {
    names: {
        'margin': 'm',
        'padding': 'p',
        'width': 'w',
        'border-radius': 'rounded',
    },
});

export default s;

This generates class names like ._m:sm, ._p:md, ._w:full, and ._rounded:lg instead of the default ._margin:sm, ._padding:md, ._width:full, and ._border-radius:lg.

Accessibility

OptionCSS PropertyDescription
forcedColorAdjustforced-color-adjustForced color adjustment values

Backgrounds

OptionCSS PropertyDescription
backgroundAttachmentbackground-attachmentBackground attachment values (fixed, local, scroll)
backgroundClipbackground-clipBackground clipping values (border-box, padding-box, content-box, text)
backgroundImagebackground-imageBackground image values (gradients, none)
backgroundOriginbackground-originBackground origin values (border-box, padding-box, content-box)
backgroundPositionbackground-positionBackground position values (center, top, bottom, etc.)
backgroundRepeatbackground-repeatBackground repeat values (repeat, no-repeat, repeat-x, etc.)
backgroundSizebackground-sizeBackground size values (auto, cover, contain)

Effects

OptionCSS PropertyDescription
backgroundBlendModebackground-blend-modeBackground blend mode values (normal, multiply, screen, etc.)
mixBlendModemix-blend-modeMix blend mode values (normal, multiply, screen, etc.)

Borders

OptionCSS PropertyDescription
divideStyleborder-style (children)Divide style values (solid, dashed, dotted, etc.)
outlineStyleoutline-styleOutline style values (none, solid, dashed, etc.)

Flexbox & Grid

OptionCSS PropertyDescription
flexflexFlex shorthand values (1, auto, initial, none)
flexDirectionflex-directionFlex direction values (row, row-reverse, column, column-reverse)
flexWrapflex-wrapFlex wrap values (wrap, wrap-reverse, nowrap)
justifyContentjustify-contentJustify content values (start, end, center, between, around, evenly)
justifyItemsjustify-itemsJustify items values (start, end, center, stretch)
justifySelfjustify-selfJustify self values (auto, start, end, center, stretch)
alignContentalign-contentAlign content values (start, end, center, between, around, evenly)
alignItemsalign-itemsAlign items values (start, end, center, baseline, stretch)
alignSelfalign-selfAlign self values (auto, start, end, center, baseline, stretch)
placeContentplace-contentPlace content values (start, end, center, between, around, evenly)
placeItemsplace-itemsPlace items values (start, end, center, baseline, stretch)
placeSelfplace-selfPlace self values (auto, start, end, center, stretch)
gridAutoFlowgrid-auto-flowGrid auto flow values (row, column, dense, row-dense, column-dense)

Interactivity

OptionCSS PropertyDescription
appearanceappearanceAppearance values (none, auto)
colorSchemecolor-schemeColor scheme values (normal, light, dark)
cursorcursorCursor values (auto, pointer, wait, text, move, etc.)
pointerEventspointer-eventsPointer events values (auto, none)
resizeresizeResize values (none, both, horizontal, vertical)
scrollBehaviorscroll-behaviorScroll behavior values (auto, smooth)
scrollSnapAlignscroll-snap-alignScroll snap align values (start, end, center, none)
scrollSnapStopscroll-snap-stopScroll snap stop values (normal, always)
scrollSnapTypescroll-snap-typeScroll snap type values (none, x, y, both, mandatory, proximity)
touchActiontouch-actionTouch action values (auto, none, manipulation, pan-x, pan-y, etc.)
userSelectuser-selectUser select values (auto, none, text, all)
willChangewill-changeWill change values (auto, scroll-position, contents, transform)

Layout

OptionCSS PropertyDescription
aspectRatioaspect-ratioAspect ratio values (auto, square, video)
boxDecorationBreakbox-decoration-breakBox decoration break values (clone, slice)
boxSizingbox-sizingBox sizing values (border-box, content-box)
breakAfterbreak-afterBreak after values (auto, avoid, all, page, column, etc.)
breakBeforebreak-beforeBreak before values (auto, avoid, all, page, column, etc.)
breakInsidebreak-insideBreak inside values (auto, avoid, avoid-page, avoid-column)
clearclearClear values (start, end, left, right, both, none)
displaydisplayDisplay values (block, inline, flex, grid, none, etc.)
floatfloatFloat values (start, end, left, right, none)
isolationisolationIsolation values (isolate, auto)
objectFitobject-fitObject fit values (contain, cover, fill, none, scale-down)
objectPositionobject-positionObject position values (center, top, bottom, left, right, etc.)
overflowoverflowOverflow values (auto, hidden, clip, visible, scroll)
overscrolloverscroll-behaviorOverscroll values (auto, contain, none)
positionpositionPosition values (static, fixed, absolute, relative, sticky)
visibilityvisibilityVisibility values (visible, invisible, collapse)

Tables

OptionCSS PropertyDescription
borderCollapseborder-collapseBorder collapse values (collapse, separate)
captionSidecaption-sideCaption side values (top, bottom)
tableLayouttable-layoutTable layout values (auto, fixed)

Transforms

OptionCSS PropertyDescription
backfaceVisibilitybackface-visibilityBackface visibility values (visible, hidden)
perspectiveOriginperspective-originPerspective origin values (center, top, bottom, left, right, etc.)
transformOrigintransform-originTransform origin values (center, top, bottom, left, right, etc.)
transformStyletransform-styleTransform style values (flat, preserve-3d)

Transitions & Animation

OptionCSS PropertyDescription
animationanimationAnimation preset values (none, spin, ping, pulse, bounce)
transitionBehaviortransition-behaviorTransition behavior values (normal, allow-discrete)
transitionPropertytransition-propertyTransition property values (none, all, colors, opacity, shadow, transform)

Typography

OptionCSS PropertyDescription
fontSmoothing-webkit-font-smoothingFont smoothing values (antialiased, subpixel-antialiased)
fontStretchfont-stretchFont stretch values (ultra-condensed, condensed, normal, expanded, etc.)
fontVariantNumericfont-variant-numericFont variant numeric values (normal, ordinal, slashed-zero, etc.)
hyphenshyphensHyphenation values (none, manual, auto)
listStylePositionlist-style-positionList style position values (inside, outside)
listStyleTypelist-style-typeList style type values (none, disc, decimal, etc.)
overflowWrapoverflow-wrapOverflow wrap values (normal, break-word)
textAligntext-alignText alignment values (left, center, right, justify, start, end)
textDecorationLinetext-decoration-lineText decoration line values (none, underline, overline, line-through)
textDecorationStyletext-decoration-styleText decoration style values (solid, double, dotted, dashed, wavy)
textOverflowtext-overflowText overflow values (clip, ellipsis)
textTransformtext-transformText transform values (none, uppercase, lowercase, capitalize)
textWraptext-wrapText wrap values (wrap, nowrap, balance, pretty)
verticalAlignvertical-alignVertical alignment values (baseline, top, middle, bottom, etc.)
whitespacewhite-spaceWhitespace values (normal, nowrap, pre, pre-line, pre-wrap, break-spaces)
wordBreakword-breakWord 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);

Pre-generating Utility Values

When using the Styleframe Vite plugin, the scanner automatically detects utility class names in your source files and generates the corresponding CSS — so you don't need to manually define values. However, if you want to pre-generate specific utility values tied to your design tokens, you can use the returned creator functions:

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 FunctionCSS PropertyClass Pattern
createForcedColorAdjustUtilityforced-color-adjust_forced-color-adjust:*
createSrOnlyUtility(multiple)_sr-only:*
createNotSrOnlyUtility(multiple)_not-sr-only:*

Backgrounds

Creator FunctionCSS PropertyClass Pattern
createBackgroundAttachmentUtilitybackground-attachment_background-attachment:*
createBackgroundClipUtilitybackground-clip_background-clip:*
createBackgroundColorUtilitybackground-color_background-color:*
createBackgroundImageUtilitybackground-image_background-image:*
createBackgroundUtilitybackground_background:*
createBackgroundOriginUtilitybackground-origin_background-origin:*
createBackgroundPositionUtilitybackground-position_background-position:*
createBackgroundRepeatUtilitybackground-repeat_background-repeat:*
createBackgroundSizeUtilitybackground-size_background-size:*
createGradientFromUtilitygradient-from_gradient-from:*
createGradientToUtilitygradient-to_gradient-to:*
createGradientViaUtilitygradient-via_gradient-via:*

Borders

Creator FunctionCSS PropertyClass Pattern
createBorderColorUtilityborder-color_border-color:*
createBorderColorTopUtilityborder-top-color_border-top-color:*
createBorderColorRightUtilityborder-right-color_border-right-color:*
createBorderColorBottomUtilityborder-bottom-color_border-bottom-color:*
createBorderColorLeftUtilityborder-left-color_border-left-color:*
createBorderColorXUtilityborder-left/right-color_border-x-color:*
createBorderColorYUtilityborder-top/bottom-color_border-y-color:*
createBorderColorStartUtilityborder-inline-start-color_border-inline-start-color:*
createBorderColorEndUtilityborder-inline-end-color_border-inline-end-color:*
createBorderRadiusUtilityborder-radius_border-radius:*
createBorderRadiusTopUtilityborder-top-*-radius_border-radius-top:*
createBorderRadiusRightUtilityborder-*-right-radius_border-radius-right:*
createBorderRadiusBottomUtilityborder-bottom-*-radius_border-radius-bottom:*
createBorderRadiusLeftUtilityborder-*-left-radius_border-radius-left:*
createBorderRadiusTopLeftUtilityborder-top-left-radius_border-radius-top-left:*
createBorderRadiusTopRightUtilityborder-top-right-radius_border-radius-top-right:*
createBorderRadiusBottomLeftUtilityborder-bottom-left-radius_border-radius-bottom-left:*
createBorderRadiusBottomRightUtilityborder-bottom-right-radius_border-radius-bottom-right:*
createBorderRadiusStartUtilityborder-start-*-radius_border-radius-start:*
createBorderRadiusEndUtilityborder-end-*-radius_border-radius-end:*
createBorderRadiusStartStartUtilityborder-start-start-radius_border-radius-start-start:*
createBorderRadiusStartEndUtilityborder-start-end-radius_border-radius-start-end:*
createBorderRadiusEndStartUtilityborder-end-start-radius_border-radius-end-start:*
createBorderRadiusEndEndUtilityborder-end-end-radius_border-radius-end-end:*
createBorderStyleUtilityborder-style_border-style:*
createBorderWidthUtilityborder-width_border-width:*
createBorderWidthTopUtilityborder-top-width_border-width-top:*
createBorderWidthRightUtilityborder-right-width_border-width-right:*
createBorderWidthBottomUtilityborder-bottom-width_border-width-bottom:*
createBorderWidthLeftUtilityborder-left-width_border-width-left:*
createBorderWidthXUtilityborder-left/right-width_border-width-x:*
createBorderWidthYUtilityborder-top/bottom-width_border-width-y:*
createBorderWidthStartUtilityborder-inline-start-width_border-width-start:*
createBorderWidthEndUtilityborder-inline-end-width_border-width-end:*
createDivideColorUtilityborder-color (children)_divide-color:*
createDivideStyleUtilityborder-style (children)_divide-style:*
createDivideXUtilityborder-left-width_divide-x:*
createDivideXReverseUtilitydivide-x-reverse_divide-x-reverse:*
createDivideYUtilityborder-top-width_divide-y:*
createDivideYReverseUtilitydivide-y-reverse_divide-y-reverse:*
createOutlineColorUtilityoutline-color_outline-color:*
createOutlineOffsetUtilityoutline-offset_outline-offset:*
createOutlineStyleUtilityoutline-style_outline-style:*
createOutlineWidthUtilityoutline-width_outline-width:*
createRingColorUtilityring-color_ring-color:*
createRingInsetUtilityring-inset_ring-inset:*
createRingOffsetColorUtilityring-offset-color_ring-offset-color:*
createRingOffsetWidthUtilityring-offset-width_ring-offset-width:*
createRingWidthUtilitybox-shadow (ring)_ring-width:*

Effects

Creator FunctionCSS PropertyClass Pattern
createBackgroundBlendModeUtilitybackground-blend-mode_background-blend-mode:*
createBoxShadowUtilitybox-shadow_box-shadow:*
createBoxShadowColorUtilitybox-shadow-color_box-shadow-color:*
createMixBlendModeUtilitymix-blend-mode_mix-blend-mode:*
createOpacityUtilityopacity_opacity:*
createTextShadowUtilitytext-shadow_text-shadow:*
createTextShadowColorUtilitytext-shadow-color_text-shadow-color:*

Filters

Creator FunctionCSS PropertyClass Pattern
createBackdropBlurUtilitybackdrop-filter: blur()_backdrop-blur:*
createBackdropBrightnessUtilitybackdrop-filter: brightness()_backdrop-brightness:*
createBackdropContrastUtilitybackdrop-filter: contrast()_backdrop-contrast:*
createBackdropGrayscaleUtilitybackdrop-filter: grayscale()_backdrop-grayscale:*
createBackdropHueRotateUtilitybackdrop-filter: hue-rotate()_backdrop-hue-rotate:*
createBackdropInvertUtilitybackdrop-filter: invert()_backdrop-invert:*
createBackdropOpacityUtilitybackdrop-filter: opacity()_backdrop-opacity:*
createBackdropSaturateUtilitybackdrop-filter: saturate()_backdrop-saturate:*
createBackdropSepiaUtilitybackdrop-filter: sepia()_backdrop-sepia:*
createBlurUtilityfilter: blur()_blur:*
createBrightnessUtilityfilter: brightness()_brightness:*
createContrastUtilityfilter: contrast()_contrast:*
createDropShadowUtilityfilter: drop-shadow()_drop-shadow:*
createGrayscaleUtilityfilter: grayscale()_grayscale:*
createHueRotateUtilityfilter: hue-rotate()_hue-rotate:*
createInvertUtilityfilter: invert()_invert:*
createSaturateUtilityfilter: saturate()_saturate:*
createSepiaUtilityfilter: sepia()_sepia:*

Flexbox & Grid

Creator FunctionCSS PropertyClass Pattern
createAlignContentUtilityalign-content_align-content:*
createAlignItemsUtilityalign-items_align-items:*
createAlignSelfUtilityalign-self_align-self:*
createFlexUtilityflex_flex:*
createFlexBasisUtilityflex-basis_flex-basis:*
createFlexDirectionUtilityflex-direction_flex-direction:*
createFlexGrowUtilityflex-grow_flex-grow:*
createFlexShrinkUtilityflex-shrink_flex-shrink:*
createFlexWrapUtilityflex-wrap_flex-wrap:*
createGapUtilitygap_gap:*
createGapXUtilitycolumn-gap_gap-x:*
createGapYUtilityrow-gap_gap-y:*
createGridAutoColumnsUtilitygrid-auto-columns_grid-auto-columns:*
createGridAutoFlowUtilitygrid-auto-flow_grid-auto-flow:*
createGridAutoRowsUtilitygrid-auto-rows_grid-auto-rows:*
createGridColumnUtilitygrid-column_grid-column:*
createGridColumnEndUtilitygrid-column-end_grid-column-end:*
createGridColumnStartUtilitygrid-column-start_grid-column-start:*
createGridRowUtilitygrid-row_grid-row:*
createGridRowEndUtilitygrid-row-end_grid-row-end:*
createGridRowStartUtilitygrid-row-start_grid-row-start:*
createGridTemplateColumnsUtilitygrid-template-columns_grid-template-columns:*
createGridTemplateRowsUtilitygrid-template-rows_grid-template-rows:*
createJustifyContentUtilityjustify-content_justify-content:*
createJustifyItemsUtilityjustify-items_justify-items:*
createJustifySelfUtilityjustify-self_justify-self:*
createOrderUtilityorder_order:*
createPlaceContentUtilityplace-content_place-content:*
createPlaceItemsUtilityplace-items_place-items:*
createPlaceSelfUtilityplace-self_place-self:*

Interactivity

Creator FunctionCSS PropertyClass Pattern
createAccentColorUtilityaccent-color_accent-color:*
createAppearanceUtilityappearance_appearance:*
createCaretColorUtilitycaret-color_caret-color:*
createColorSchemeUtilitycolor-scheme_color-scheme:*
createCursorUtilitycursor_cursor:*
createPointerEventsUtilitypointer-events_pointer-events:*
createResizeUtilityresize_resize:*
createScrollBehaviorUtilityscroll-behavior_scroll-behavior:*
createScrollMarginUtilityscroll-margin_scroll-margin:*
createScrollMarginTopUtilityscroll-margin-top_scroll-margin-top:*
createScrollMarginRightUtilityscroll-margin-right_scroll-margin-right:*
createScrollMarginBottomUtilityscroll-margin-bottom_scroll-margin-bottom:*
createScrollMarginLeftUtilityscroll-margin-left_scroll-margin-left:*
createScrollMarginXUtilityscroll-margin-left/right_scroll-margin-x:*
createScrollMarginYUtilityscroll-margin-top/bottom_scroll-margin-y:*
createScrollMarginStartUtilityscroll-margin-inline-start_scroll-margin-start:*
createScrollMarginEndUtilityscroll-margin-inline-end_scroll-margin-end:*
createScrollPaddingUtilityscroll-padding_scroll-padding:*
createScrollPaddingTopUtilityscroll-padding-top_scroll-padding-top:*
createScrollPaddingRightUtilityscroll-padding-right_scroll-padding-right:*
createScrollPaddingBottomUtilityscroll-padding-bottom_scroll-padding-bottom:*
createScrollPaddingLeftUtilityscroll-padding-left_scroll-padding-left:*
createScrollPaddingXUtilityscroll-padding-left/right_scroll-padding-x:*
createScrollPaddingYUtilityscroll-padding-top/bottom_scroll-padding-y:*
createScrollPaddingStartUtilityscroll-padding-inline-start_scroll-padding-start:*
createScrollPaddingEndUtilityscroll-padding-inline-end_scroll-padding-end:*
createScrollSnapAlignUtilityscroll-snap-align_scroll-snap-align:*
createScrollSnapStopUtilityscroll-snap-stop_scroll-snap-stop:*
createScrollSnapTypeUtilityscroll-snap-type_scroll-snap-type:*
createTouchActionUtilitytouch-action_touch-action:*
createUserSelectUtilityuser-select_user-select:*
createWillChangeUtilitywill-change_will-change:*

Layout

Creator FunctionCSS PropertyClass Pattern
createAspectRatioUtilityaspect-ratio_aspect-ratio:*
createBottomUtilitybottom_bottom:*
createBoxDecorationBreakUtilitybox-decoration-break_box-decoration-break:*
createBoxSizingUtilitybox-sizing_box-sizing:*
createBreakAfterUtilitybreak-after_break-after:*
createBreakBeforeUtilitybreak-before_break-before:*
createBreakInsideUtilitybreak-inside_break-inside:*
createClearUtilityclear_clear:*
createColumnsUtilitycolumns_columns:*
createDisplayUtilitydisplay_display:*
createFloatUtilityfloat_float:*
createInsetUtilityinset_inset:*
createInsetXUtilityleft + right_inset-x:*
createInsetYUtilitytop + bottom_inset-y:*
createInsetStartUtilityinset-inline-start_inset-start:*
createInsetEndUtilityinset-inline-end_inset-end:*
createIsolationUtilityisolation_isolation:*
createLeftUtilityleft_left:*
createObjectFitUtilityobject-fit_object-fit:*
createObjectPositionUtilityobject-position_object-position:*
createOverflowUtilityoverflow_overflow:*
createOverflowXUtilityoverflow-x_overflow-x:*
createOverflowYUtilityoverflow-y_overflow-y:*
createOverscrollUtilityoverscroll-behavior_overscroll:*
createOverscrollXUtilityoverscroll-behavior-x_overscroll-x:*
createOverscrollYUtilityoverscroll-behavior-y_overscroll-y:*
createPositionUtilityposition_position:*
createRightUtilityright_right:*
createTopUtilitytop_top:*
createVisibilityUtilityvisibility_visibility:*
createZIndexUtilityz-index_z-index:*

Sizing

Creator FunctionCSS PropertyClass Pattern
createHeightUtilityheight_height:*
createMaxHeightUtilitymax-height_max-height:*
createMaxWidthUtilitymax-width_max-width:*
createMinHeightUtilitymin-height_min-height:*
createMinWidthUtilitymin-width_min-width:*
createSizeUtilitywidth + height_size:*
createWidthUtilitywidth_width:*

Spacing

Creator FunctionCSS PropertyClass Pattern
createMarginUtilitymargin_margin:*
createMarginTopUtilitymargin-top_margin-top:*
createMarginRightUtilitymargin-right_margin-right:*
createMarginBottomUtilitymargin-bottom_margin-bottom:*
createMarginLeftUtilitymargin-left_margin-left:*
createMarginXUtilitymargin-left + margin-right_margin-x:*
createMarginYUtilitymargin-top + margin-bottom_margin-y:*
createMarginInlineUtilitymargin-inline_margin-inline:*
createMarginInlineStartUtilitymargin-inline-start_margin-inline-start:*
createMarginInlineEndUtilitymargin-inline-end_margin-inline-end:*
createMarginBlockUtilitymargin-block_margin-block:*
createPaddingUtilitypadding_padding:*
createPaddingTopUtilitypadding-top_padding-top:*
createPaddingRightUtilitypadding-right_padding-right:*
createPaddingBottomUtilitypadding-bottom_padding-bottom:*
createPaddingLeftUtilitypadding-left_padding-left:*
createPaddingXUtilitypadding-left + padding-right_padding-x:*
createPaddingYUtilitypadding-top + padding-bottom_padding-y:*
createPaddingInlineUtilitypadding-inline_padding-inline:*
createPaddingInlineStartUtilitypadding-inline-start_padding-inline-start:*
createPaddingInlineEndUtilitypadding-inline-end_padding-inline-end:*
createPaddingBlockUtilitypadding-block_padding-block:*
createSpaceXUtilitymargin-left (children)_space-x:*
createSpaceXReverseUtilityspace-x-reverse_space-x-reverse:*
createSpaceYUtilitymargin-top (children)_space-y:*
createSpaceYReverseUtilityspace-y-reverse_space-y-reverse:*

SVG

Creator FunctionCSS PropertyClass Pattern
createFillUtilityfill_fill:*
createStrokeUtilitystroke_stroke:*
createStrokeWidthUtilitystroke-width_stroke-width:*

Tables

Creator FunctionCSS PropertyClass Pattern
createBorderCollapseUtilityborder-collapse_border-collapse:*
createBorderSpacingUtilityborder-spacing_border-spacing:*
createBorderSpacingXUtilityborder-spacing (horizontal)_border-spacing-x:*
createBorderSpacingYUtilityborder-spacing (vertical)_border-spacing-y:*
createCaptionSideUtilitycaption-side_caption-side:*
createTableLayoutUtilitytable-layout_table-layout:*

Transforms

Creator FunctionCSS PropertyClass Pattern
createBackfaceVisibilityUtilitybackface-visibility_backface-visibility:*
createPerspectiveUtilityperspective_perspective:*
createPerspectiveOriginUtilityperspective-origin_perspective-origin:*
createRotateUtilityrotate_rotate:*
createRotateXUtilityrotate-x_rotate-x:*
createRotateYUtilityrotate-y_rotate-y:*
createScaleUtilityscale_scale:*
createScaleXUtilityscale-x_scale-x:*
createScaleYUtilityscale-y_scale-y:*
createSkewXUtilityskew-x_skew-x:*
createSkewYUtilityskew-y_skew-y:*
createTransformOriginUtilitytransform-origin_transform-origin:*
createTransformStyleUtilitytransform-style_transform-style:*
createTranslateUtilitytranslate_translate:*
createTranslateXUtilitytranslate-x_translate-x:*
createTranslateYUtilitytranslate-y_translate-y:*
createTranslateZUtilitytranslate-z_translate-z:*

Transitions & Animation

Creator FunctionCSS PropertyClass Pattern
createAnimationUtilityanimation_animation:*
createTransitionBehaviorUtilitytransition-behavior_transition-behavior:*
createTransitionDelayUtilitytransition-delay_transition-delay:*
createTransitionDurationUtilitytransition-duration_transition-duration:*
createTransitionPropertyUtilitytransition-property_transition-property:*
createTransitionTimingFunctionUtilitytransition-timing-function_transition-timing-function:*

Typography

Creator FunctionCSS PropertyClass Pattern
createColorUtilitycolor_color:*
createContentUtilitycontent_content:*
createFontFamilyUtilityfont-family_font-family:*
createFontSizeUtilityfont-size_font-size:*
createFontSmoothingUtility-webkit-font-smoothing_font-smoothing:*
createFontStretchUtilityfont-stretch_font-stretch:*
createFontStyleUtilityfont-style_font-style:*
createFontVariantNumericUtilityfont-variant-numeric_font-variant-numeric:*
createFontWeightUtilityfont-weight_font-weight:*
createHyphensUtilityhyphens_hyphens:*
createLetterSpacingUtilityletter-spacing_letter-spacing:*
createLineClampUtility-webkit-line-clamp_line-clamp:*
createLineHeightUtilityline-height_line-height:*
createListStyleImageUtilitylist-style-image_list-style-image:*
createListStylePositionUtilitylist-style-position_list-style-position:*
createListStyleTypeUtilitylist-style-type_list-style-type:*
createOverflowWrapUtilityoverflow-wrap_overflow-wrap:*
createTextAlignUtilitytext-align_text-align:*
createTextColorUtilitycolor_text-color:*
createTextDecorationColorUtilitytext-decoration-color_text-decoration-color:*
createTextDecorationLineUtilitytext-decoration-line_text-decoration-line:*
createTextDecorationStyleUtilitytext-decoration-style_text-decoration-style:*
createTextDecorationThicknessUtilitytext-decoration-thickness_text-decoration-thickness:*
createTextIndentUtilitytext-indent_text-indent:*
createTextOverflowUtilitytext-overflow_text-overflow:*
createTextTransformUtilitytext-transform_text-transform:*
createTextUnderlineOffsetUtilitytext-underline-offset_text-underline-offset:*
createTextWrapUtilitytext-wrap_text-wrap:*
createVerticalAlignUtilityvertical-align_vertical-align:*
createWhitespaceUtilitywhite-space_whitespace:*
createWordBreakUtilityword-break_word-break:*

useShorthandUtilitiesPreset

A convenience wrapper around useUtilitiesPreset that applies TailwindCSS-style shorthand class names. Instead of ._margin:sm, you get ._m:sm.

Signature

function useShorthandUtilitiesPreset(
    s: Styleframe,
    config?: UtilitiesPresetConfig
): Record<string, UtilityCreator>

All configuration options from useUtilitiesPreset are supported. Custom names provided in config.names override the shorthand defaults.

Quick Start

styleframe.config.ts
import { styleframe } from 'styleframe';
import { useShorthandUtilitiesPreset } from '@styleframe/theme';

const s = styleframe();

// Register all utilities with Tailwind-style shorthand names
const utilities = useShorthandUtilitiesPreset(s);

export default s;

Shorthand Name Mappings

The preset includes 80+ shorthand mappings across all utility categories. The full mapping is also exported as shorthandNames from @styleframe/theme for reference or extension.

Spacing

Default NameShorthand
marginm
margin-topmt
margin-rightmr
margin-bottommb
margin-leftml
margin-inlinemx
margin-blockmy
margin-inline-startms
margin-inline-endme
paddingp
padding-toppt
padding-rightpr
padding-bottompb
padding-leftpl
padding-inlinepx
padding-blockpy
padding-inline-startps
padding-inline-endpe

Sizing

Default NameShorthand
widthw
min-widthmin-w
max-widthmax-w
heighth
min-heightmin-h
max-heightmax-h

Typography

Default NameShorthand
font-sizetext
font-weightfont
line-heightleading
letter-spacingtracking
text-decoration-linedecoration
text-decoration-colordecoration-color
text-decoration-styledecoration-style
text-decoration-thicknessdecoration-thickness
text-underline-offsetunderline-offset
text-indentindent
vertical-alignalign
word-breakbreak
list-style-imagelist-image
list-style-typelist

Layout

Default NameShorthand
z-indexz
inset-inline-startstart
inset-inline-endend
aspect-ratioaspect
isolationisolate
box-sizingbox
box-decoration-breakbox-decoration

Flexbox & Grid

Default NameShorthand
flex-growgrow
flex-shrinkshrink
flex-basisbasis
justify-contentjustify
align-itemsitems
align-selfself
grid-template-columnsgrid-cols
grid-template-rowsgrid-rows
grid-columncol
grid-column-startcol-start
grid-column-endcol-end
grid-rowrow
grid-row-startrow-start
grid-row-endrow-end
grid-auto-flowgrid-flow
grid-auto-columnsauto-cols
grid-auto-rowsauto-rows

Borders

Default NameShorthand
border-widthborder
border-x-widthborder-x
border-y-widthborder-y
border-top-widthborder-t
border-right-widthborder-r
border-bottom-widthborder-b
border-left-widthborder-l
border-inline-start-widthborder-s
border-inline-end-widthborder-e
border-top-colorborder-t-color
border-right-colorborder-r-color
border-bottom-colorborder-b-color
border-left-colorborder-l-color
border-inline-start-colorborder-s-color
border-inline-end-colorborder-e-color
border-radiusrounded
border-radius-toprounded-t
border-radius-rightrounded-r
border-radius-bottomrounded-b
border-radius-leftrounded-l
border-radius-startrounded-s
border-radius-endrounded-e
border-top-left-radiusrounded-tl
border-top-right-radiusrounded-tr
border-bottom-right-radiusrounded-br
border-bottom-left-radiusrounded-bl
border-start-start-radiusrounded-ss
border-start-end-radiusrounded-se
border-end-end-radiusrounded-ee
border-end-start-radiusrounded-es
outline-widthoutline

Effects

Default NameShorthand
box-shadowshadow
box-shadow-colorshadow-color
background-blend-modebg-blend
mix-blend-modemix-blend

Backgrounds

Default NameShorthand
background-colorbg
background-attachmentbg-attachment
background-clipbg-clip
background-originbg-origin
background-positionbg-position
background-repeatbg-repeat
background-sizebg-size
gradient-fromfrom
gradient-viavia
gradient-toto

Transforms

Default NameShorthand
transform-originorigin
backface-visibilitybackface

Transitions & Animation

Default NameShorthand
transition-propertytransition
transition-durationduration
transition-timing-functionease
transition-delaydelay

Tables

Default NameShorthand
table-layouttable
caption-sidecaption

Interactivity

Default NameShorthand
accent-coloraccent
caret-colorcaret
color-schemescheme
scroll-behaviorscroll
scroll-snap-alignsnap
scroll-snap-stopsnap-stop
scroll-snap-typesnap-type
scroll-marginscroll-m
scroll-margin-xscroll-mx
scroll-margin-yscroll-my
scroll-margin-topscroll-mt
scroll-margin-rightscroll-mr
scroll-margin-bottomscroll-mb
scroll-margin-leftscroll-ml
scroll-margin-inline-startscroll-ms
scroll-margin-inline-endscroll-me
scroll-paddingscroll-p
scroll-padding-xscroll-px
scroll-padding-yscroll-py
scroll-padding-topscroll-pt
scroll-padding-rightscroll-pr
scroll-padding-bottomscroll-pb
scroll-padding-leftscroll-pl
scroll-padding-inline-startscroll-ps
scroll-padding-inline-endscroll-pe
touch-actiontouch
user-selectselect

Overriding Shorthand Names

Pass config.names to override specific shorthand defaults:

styleframe.config.ts
import { styleframe } from 'styleframe';
import { useShorthandUtilitiesPreset } from '@styleframe/theme';

const s = styleframe();

const utilities = useShorthandUtilitiesPreset(s, {
    names: {
        'margin': 'margin', // Keep the default name for margin
        'padding': 'pad',   // Use a custom name instead of 'p'
    },
});

export default s;

Examples

Full Recipe Integration

styleframe.config.ts
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
  • Combine with modifiers: Use useModifiersPreset() alongside useUtilitiesPreset() to register modifier factories for state-based variants

FAQ