Home / Type/ Variant Type — tailwindcss Architecture

Variant Type — tailwindcss Architecture

Architecture documentation for the Variant type/interface in candidate.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  87f06d1e_9447_9918_8264_b379dd1ec5e9["Variant"]
  669e6a28_c71f_3c5e_9c53_915cede7da78["candidate.ts"]
  87f06d1e_9447_9918_8264_b379dd1ec5e9 -->|defined in| 669e6a28_c71f_3c5e_9c53_915cede7da78
  style 87f06d1e_9447_9918_8264_b379dd1ec5e9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/candidate.ts lines 103–162

export type Variant =
  /**
   * Arbitrary variants are variants that take a selector and generate a variant
   * on the fly.
   *
   * E.g.: `[&_p]`
   */
  | {
      kind: 'arbitrary'
      selector: string

      // Whether or not the selector is a relative selector
      // @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors/Selector_structure#relative_selector
      relative: boolean
    }

  /**
   * Static variants are variants that don't take any arguments.
   *
   * E.g.: `hover`
   */
  | {
      kind: 'static'
      root: string
    }

  /**
   * Functional variants are variants that can take an argument. The argument is
   * either a named variant value or an arbitrary variant value.
   *
   * E.g.:
   *
   * - `aria-disabled`
   * - `aria-[disabled]`
   * - `@container-size`          -> @container, with named value `size`
   * - `@container-[inline-size]` -> @container, with arbitrary variant value `inline-size`
   * - `@container`               -> @container, with no value
   */
  | {
      kind: 'functional'
      root: string
      value: ArbitraryVariantValue | NamedVariantValue | null
      modifier: ArbitraryModifier | NamedModifier | null
    }

  /**
   * Compound variants are variants that take another variant as an argument.
   *
   * E.g.:
   *
   * - `has-[&_p]`
   * - `group-*`
   * - `peer-*`
   */
  | {
      kind: 'compound'
      root: string
      modifier: ArbitraryModifier | NamedModifier | null
      variant: Variant
    }

Frequently Asked Questions

What is the Variant type?
Variant is a type/interface in the tailwindcss codebase, defined in packages/tailwindcss/src/candidate.ts.
Where is Variant defined?
Variant is defined in packages/tailwindcss/src/candidate.ts at line 103.

Analyze Your Own Codebase

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

Try Supermodel Free