Home / Function/ add() — tailwindcss Function Reference

add() — tailwindcss Function Reference

Architecture documentation for the add() function in theme.ts from the tailwindcss codebase.

Function typescript Oxide PreProcessors calls 2 called by 16

Entity Profile

Dependency Diagram

graph TD
  e7db6358_7af5_e4b2_792d_749691a304cc["add()"]
  e7a2e966_188e_28f5_d9d6_e54e27e0d0f2["Theme"]
  e7db6358_7af5_e4b2_792d_749691a304cc -->|defined in| e7a2e966_188e_28f5_d9d6_e54e27e0d0f2
  9f2a64dc_05ff_3425_1af8_f2dbd33c3b9a["optimizeAst()"]
  9f2a64dc_05ff_3425_1af8_f2dbd33c3b9a -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  1a695257_28e4_0604_3f02_e52886aa117e["isVariableUsed()"]
  1a695257_28e4_0604_3f02_e52886aa117e -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  fc54d77f_8791_78d0_76a3_105cb9c395cf["canonicalizeCandidates()"]
  fc54d77f_8791_78d0_76a3_105cb9c395cf -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  fd4a6387_6427_eb54_6f14_abd89a3baf61["collapseCandidates()"]
  fd4a6387_6427_eb54_6f14_abd89a3baf61 -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  9d7dff21_77af_5de5_322b_3d9047c15d83["tryValueReplacements()"]
  9d7dff21_77af_5de5_322b_3d9047c15d83 -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  e559573b_f2f8_833b_27e7_100efea815c0["canonicalizeAst()"]
  e559573b_f2f8_833b_27e7_100efea815c0 -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  7b28cf23_d052_57d9_b076_5abe2b724a3f["resolveVariablesInValue()"]
  7b28cf23_d052_57d9_b076_5abe2b724a3f -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  2fa686dc_af14_1b06_e253_cd3be040c4fd["createUtilityPropertiesCache()"]
  2fa686dc_af14_1b06_e253_cd3be040c4fd -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  a661983a_5661_09de_3802_5c161f8f271c["temporarilyDisableThemeInline()"]
  a661983a_5661_09de_3802_5c161f8f271c -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  652fb7ad_2f22_0667_c96e_43b408d0edbe["applyConfigToTheme()"]
  652fb7ad_2f22_0667_c96e_43b408d0edbe -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  f7f9b3da_5977_1aa6_3bcb_bfc607af4e8f["parseCss()"]
  f7f9b3da_5977_1aa6_3bcb_bfc607af4e8f -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  95f6fed7_1762_4f0d_f308_50c6be9a770a["compileAst()"]
  95f6fed7_1762_4f0d_f308_50c6be9a770a -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  56e002cc_409f_bdfa_c573_fa69116d8c75["loadDesignSystem()"]
  56e002cc_409f_bdfa_c573_fa69116d8c75 -->|calls| e7db6358_7af5_e4b2_792d_749691a304cc
  style e7db6358_7af5_e4b2_792d_749691a304cc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/theme.ts lines 60–86

  add(key: string, value: string, options = ThemeOptions.NONE, src?: Declaration['src']): void {
    if (key.endsWith('-*')) {
      if (value !== 'initial') {
        throw new Error(`Invalid theme value \`${value}\` for namespace \`${key}\``)
      }
      if (key === '--*') {
        this.values.clear()
      } else {
        this.clearNamespace(
          key.slice(0, -2),
          // `--${key}-*: initial;` should clear _all_ theme values
          ThemeOptions.NONE,
        )
      }
    }

    if (options & ThemeOptions.DEFAULT) {
      let existing = this.values.get(key)
      if (existing && !(existing.options & ThemeOptions.DEFAULT)) return
    }

    if (value === 'initial') {
      this.values.delete(key)
    } else {
      this.values.set(key, { value, options, src })
    }
  }

Domain

Subdomains

Frequently Asked Questions

What does add() do?
add() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/theme.ts.
Where is add() defined?
add() is defined in packages/tailwindcss/src/theme.ts at line 60.
What does add() call?
add() calls 2 function(s): clearNamespace, get.
What calls add()?
add() is called by 16 function(s): addKeyframes, applyConfigToTheme, canonicalizeAst, canonicalizeCandidates, collapseCandidates, compileAst, createCssUtility, createUtilityPropertiesCache, and 8 more.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free