MCPcopy
hub / github.com/tailwindlabs/tailwindcss / #var

Method #var

packages/tailwindcss/src/theme.ts:193–208  ·  view source on GitHub ↗
(themeKey: string)

Source from the content-addressed store, hash-verified

191 }
192
193 #var(themeKey: string) {
194 let value = this.values.get(themeKey)
195 if (!value) {
196 return null
197 }
198
199 // Since @theme blocks in reference mode do not emit the CSS variables, we can not assume that
200 // the values will eventually be set up in the browser (e.g. when using `@apply` inside roots
201 // that use `@reference`). Ensure we set up a fallback in these cases.
202 let fallback = null
203 if (value.options & ThemeOptions.REFERENCE) {
204 fallback = value.value
205 }
206
207 return `var(${escape(this.prefixKey(themeKey))}${fallback ? `, ${fallback}` : ''})`
208 }
209
210 markUsedVariable(themeKey: string): boolean {
211 let key = unescape(this.#unprefixKey(themeKey))

Callers 2

resolveMethod · 0.95
resolveWithMethod · 0.95

Calls 3

prefixKeyMethod · 0.95
escapeFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected