Home / Function/ cssContext() — tailwindcss Function Reference

cssContext() — tailwindcss Function Reference

Architecture documentation for the cssContext() function in ast.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  aac1ce38_87b8_e2ee_838b_b9196b3e9299["cssContext()"]
  9e2f12c0_83ef_256b_739b_9ec6ebc69b08["applyCompatibilityHooks()"]
  9e2f12c0_83ef_256b_739b_9ec6ebc69b08 -->|calls| aac1ce38_87b8_e2ee_838b_b9196b3e9299
  0f8ac574_990e_8595_a6ed_11422b8a8ec4["upgradeToFullPluginSupport()"]
  0f8ac574_990e_8595_a6ed_11422b8a8ec4 -->|calls| aac1ce38_87b8_e2ee_838b_b9196b3e9299
  26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c["parseCss()"]
  26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c -->|calls| aac1ce38_87b8_e2ee_838b_b9196b3e9299
  5da7c62d_f734_2cbc_b10f_03c31a70d4f9["context()"]
  aac1ce38_87b8_e2ee_838b_b9196b3e9299 -->|calls| 5da7c62d_f734_2cbc_b10f_03c31a70d4f9
  style aac1ce38_87b8_e2ee_838b_b9196b3e9299 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/ast.ts lines 188–216

export function cssContext(
  ctx: VisitContext<AstNode>,
): VisitContext<AstNode> & { context: Record<string, string | boolean> } {
  return {
    depth: ctx.depth,
    get context() {
      let context: Record<string, string | boolean> = {}
      for (let child of ctx.path()) {
        if (child.kind === 'context') {
          Object.assign(context, child.context)
        }
      }

      // Once computed, we never need to compute this again
      Object.defineProperty(this, 'context', { value: context })
      return context
    },
    get parent() {
      let parent = (this.path().pop() as Extract<AstNode, { nodes: AstNode[] }>) ?? null

      // Once computed, we never need to compute this again
      Object.defineProperty(this, 'parent', { value: parent })
      return parent
    },
    path() {
      return ctx.path().filter((n) => n.kind !== 'context')
    },
  }
}

Subdomains

Calls

Frequently Asked Questions

What does cssContext() do?
cssContext() is a function in the tailwindcss codebase.
What does cssContext() call?
cssContext() calls 1 function(s): context.
What calls cssContext()?
cssContext() is called by 3 function(s): applyCompatibilityHooks, parseCss, upgradeToFullPluginSupport.

Analyze Your Own Codebase

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

Try Supermodel Free