Home / Function/ add() — tailwindcss Function Reference

add() — tailwindcss Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  3ba19013_498f_3c9b_5c44_0eb24efc4394["add()"]
  ec867cf3_916b_0d16_65ec_c715e69fee03["optimizeAst()"]
  ec867cf3_916b_0d16_65ec_c715e69fee03 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  80f64279_dc28_709a_aad4_02bea029c935["isVariableUsed()"]
  80f64279_dc28_709a_aad4_02bea029c935 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  0c93fc33_6ff1_7638_3219_621fdee3ade6["canonicalizeCandidates()"]
  0c93fc33_6ff1_7638_3219_621fdee3ade6 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  71b68838_221b_7f75_2376_3e23d6c37929["collapseCandidates()"]
  71b68838_221b_7f75_2376_3e23d6c37929 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  07e623bd_0cfb_00fb_6300_b582d8ed9fd0["tryValueReplacements()"]
  07e623bd_0cfb_00fb_6300_b582d8ed9fd0 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  84dbd847_e2eb_8fba_afa7_47012ee6086f["canonicalizeAst()"]
  84dbd847_e2eb_8fba_afa7_47012ee6086f -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  1d9d6293_9d1d_5445_6e1b_8f6256992b8a["resolveVariablesInValue()"]
  1d9d6293_9d1d_5445_6e1b_8f6256992b8a -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  1990afd0_c36f_335a_ba33_c341aee76086["createUtilityPropertiesCache()"]
  1990afd0_c36f_335a_ba33_c341aee76086 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  ff3b791b_69bb_dfca_8d4b_f92bd97ab054["temporarilyDisableThemeInline()"]
  ff3b791b_69bb_dfca_8d4b_f92bd97ab054 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  ffa1d3be_8116_7cd8_db2c_a42892f9c21a["applyConfigToTheme()"]
  ffa1d3be_8116_7cd8_db2c_a42892f9c21a -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c["parseCss()"]
  26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  6a3a8ab4_d53c_7516_c736_663c060fe979["compileAst()"]
  6a3a8ab4_d53c_7516_c736_663c060fe979 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  737df10e_833f_d962_fea9_0e7dadf43c40["loadDesignSystem()"]
  737df10e_833f_d962_fea9_0e7dadf43c40 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  bc446739_2392_65cc_e41e_055960e2ef29["simpleDesign()"]
  bc446739_2392_65cc_e41e_055960e2ef29 -->|calls| 3ba19013_498f_3c9b_5c44_0eb24efc4394
  style 3ba19013_498f_3c9b_5c44_0eb24efc4394 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 })
    }
  }

Subdomains

Frequently Asked Questions

What does add() do?
add() is a function in the tailwindcss codebase.
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