MCPcopy
hub / github.com/tailwindlabs/tailwindcss / spacingUtility

Function spacingUtility

packages/tailwindcss/src/utilities.ts:528–577  ·  packages/tailwindcss/src/utilities.ts::spacingUtility
(
    name: string,
    themeKeys: ThemeKey[],
    handle: (value: string) => AstNode[] | undefined,
    {
      supportsNegative = false,
      supportsFractions = false,
      staticValues,
    }: {
      supportsNegative?: boolean
      supportsFractions?: boolean
      staticValues?: Record<string, AstNode[]>
    } = {},
  )

Source from the content-addressed store, hash-verified

526 }
527
528 function spacingUtility(
529 name: string,
530 themeKeys: ThemeKey[],
531 handle: (value: string) => AstNode[] | undefined,
532 {
533 supportsNegative = false,
534 supportsFractions = false,
535 staticValues,
536 }: {
537 supportsNegative?: boolean
538 supportsFractions?: boolean
539 staticValues?: Record<string, AstNode[]>
540 } = {},
541 ) {
542 if (supportsNegative) {
543 utilities.static(`-${name}-px`, () => handle(class="st">'-1px'))
544 }
545 utilities.static(`${name}-px`, () => handle(class="st">'1px'))
546 functionalUtility(name, {
547 themeKeys,
548 supportsFractions,
549 supportsNegative,
550 defaultValue: null,
551 handleBareValue: ({ value }) => {
552 let multiplier = theme.resolve(null, [class="st">'--spacing'])
553 if (!multiplier) return null
554 if (!isValidSpacingMultiplier(value)) return null
555
556 return `--spacing(${value})`
557 },
558 handleNegativeBareValue: ({ value }) => {
559 let multiplier = theme.resolve(null, [class="st">'--spacing'])
560 if (!multiplier) return null
561 if (!isValidSpacingMultiplier(value)) return null
562
563 return `--spacing(-${value})`
564 },
565 handle,
566 staticValues,
567 })
568
569 suggest(name, () => [
570 {
571 values: theme.get([class="st">'--spacing']) ? DEFAULT_SPACING_SUGGESTIONS : [],
572 supportsNegative,
573 supportsFractions,
574 valueThemeKeys: themeKeys,
575 },
576 ])
577 }
578
579 /**
580 * ----------------

Callers 1

createUtilitiesFunction · 0.85

Calls 7

isValidSpacingMultiplierFunction · 0.90
handleFunction · 0.85
functionalUtilityFunction · 0.85
suggestFunction · 0.85
resolveMethod · 0.80
staticMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected