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

Function resolveThemeValue

packages/tailwindcss/src/design-system.ts:215–235  ·  view source on GitHub ↗
(path: `${ThemeKey}` | `${ThemeKey}${string}`, forceInline: boolean = true)

Source from the content-addressed store, hash-verified

213 },
214
215 resolveThemeValue(path: `${ThemeKey}` | `${ThemeKey}${string}`, forceInline: boolean = true) {
216 // Extract an eventual modifier from the path. e.g.:
217 // - "--color-red-500 / 50%" -> "50%"
218 let lastSlash = path.lastIndexOf('/')
219 let modifier: string | null = null
220 if (lastSlash !== -1) {
221 modifier = path.slice(lastSlash + 1).trim()
222 path = path.slice(0, lastSlash).trim() as ThemeKey
223 }
224
225 let themeValue =
226 theme.resolve(null, [path], forceInline ? ThemeOptions.INLINE : ThemeOptions.NONE) ??
227 undefined
228
229 // Apply the opacity modifier if present
230 if (modifier && themeValue) {
231 return withAlpha(themeValue, modifier)
232 }
233
234 return themeValue
235 },
236
237 trackUsedVariables(raw: string) {
238 trackUsedVariables.get(raw)

Callers

nothing calls this directly

Calls 2

withAlphaFunction · 0.90
resolveMethod · 0.80

Tested by

no test coverage detected