Home / Function/ alpha() — tailwindcss Function Reference

alpha() — tailwindcss Function Reference

Architecture documentation for the alpha() function in css-functions.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  9c18cb7f_2c6f_5ebe_697c_d24b3f934355["alpha()"]
  2189e39a_5595_cbd9_3bbe_eaf87ccf42a2["css-functions.ts"]
  9c18cb7f_2c6f_5ebe_697c_d24b3f934355 -->|defined in| 2189e39a_5595_cbd9_3bbe_eaf87ccf42a2
  f712ed47_45d4_4e5a_dd73_fdefa1da71da["segment()"]
  9c18cb7f_2c6f_5ebe_697c_d24b3f934355 -->|calls| f712ed47_45d4_4e5a_dd73_fdefa1da71da
  b71e300f_d366_e92d_f71f_413f7ee24e95["withAlpha()"]
  9c18cb7f_2c6f_5ebe_697c_d24b3f934355 -->|calls| b71e300f_d366_e92d_f71f_413f7ee24e95
  style 9c18cb7f_2c6f_5ebe_697c_d24b3f934355 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/css-functions.ts lines 19–40

function alpha(
  _designSystem: DesignSystem,
  _source: AstNode,
  value: string,
  ...rest: string[]
): string {
  let [color, alpha] = segment(value, '/').map((v) => v.trim())

  if (!color || !alpha) {
    throw new Error(
      `The --alpha(…) function requires a color and an alpha value, e.g.: \`--alpha(${color || 'var(--my-color)'} / ${alpha || '50%'})\``,
    )
  }

  if (rest.length > 0) {
    throw new Error(
      `The --alpha(…) function only accepts one argument, e.g.: \`--alpha(${color || 'var(--my-color)'} / ${alpha || '50%'})\``,
    )
  }

  return withAlpha(color, alpha)
}

Domain

Subdomains

Frequently Asked Questions

What does alpha() do?
alpha() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/css-functions.ts.
Where is alpha() defined?
alpha() is defined in packages/tailwindcss/src/css-functions.ts at line 19.
What does alpha() call?
alpha() calls 2 function(s): segment, withAlpha.

Analyze Your Own Codebase

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

Try Supermodel Free