Home / Function/ updateCss() — ui Function Reference

updateCss() — ui Function Reference

Architecture documentation for the updateCss() function in update-css.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  dbbf9c53_e74c_20ab_2a14_13e89d970437["updateCss()"]
  19f89ba1_d1e0_8dcc_df03_c70e9de01ca0["update-css.ts"]
  dbbf9c53_e74c_20ab_2a14_13e89d970437 -->|defined in| 19f89ba1_d1e0_8dcc_df03_c70e9de01ca0
  f51e58e3_7a1b_20d7_d56c_af590db86289["transformCss()"]
  dbbf9c53_e74c_20ab_2a14_13e89d970437 -->|calls| f51e58e3_7a1b_20d7_d56c_af590db86289
  style dbbf9c53_e74c_20ab_2a14_13e89d970437 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/utils/updaters/update-css.ts lines 14–50

export async function updateCss(
  css: z.infer<typeof registryItemCssSchema> | undefined,
  config: Config,
  options: {
    silent?: boolean
  }
) {
  if (
    !config.resolvedPaths.tailwindCss ||
    !css ||
    Object.keys(css).length === 0
  ) {
    return
  }

  options = {
    silent: false,
    ...options,
  }

  const cssFilepath = config.resolvedPaths.tailwindCss
  const cssFilepathRelative = path.relative(
    config.resolvedPaths.cwd,
    cssFilepath
  )
  const cssSpinner = spinner(
    `Updating ${highlighter.info(cssFilepathRelative)}`,
    {
      silent: options.silent,
    }
  ).start()

  const raw = await fs.readFile(cssFilepath, "utf8")
  let output = await transformCss(raw, css)
  await fs.writeFile(cssFilepath, output, "utf8")
  cssSpinner.succeed()
}

Subdomains

Frequently Asked Questions

What does updateCss() do?
updateCss() is a function in the ui codebase, defined in packages/shadcn/src/utils/updaters/update-css.ts.
Where is updateCss() defined?
updateCss() is defined in packages/shadcn/src/utils/updaters/update-css.ts at line 14.
What does updateCss() call?
updateCss() calls 1 function(s): transformCss.

Analyze Your Own Codebase

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

Try Supermodel Free