addTailwindConfigProperty() — ui Function Reference
Architecture documentation for the addTailwindConfigProperty() function in update-tailwind-config.ts from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 8c513282_9511_c3df_77df_ed2abc37385a["addTailwindConfigProperty()"] ef3e192c_eced_bc46_1021_689faf6b7065["update-tailwind-config.ts"] 8c513282_9511_c3df_77df_ed2abc37385a -->|defined in| ef3e192c_eced_bc46_1021_689faf6b7065 bcd6344c_3146_377d_9fd0_f68ae594bdfb["transformTailwindConfig()"] bcd6344c_3146_377d_9fd0_f68ae594bdfb -->|calls| 8c513282_9511_c3df_77df_ed2abc37385a style 8c513282_9511_c3df_77df_ed2abc37385a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/shadcn/src/utils/updaters/update-tailwind-config.ts lines 124–184
function addTailwindConfigProperty(
configObject: ObjectLiteralExpression,
property: {
name: string
value: string
},
{
quoteChar,
}: {
quoteChar: string
}
) {
const existingProperty = configObject.getProperty("darkMode")
if (!existingProperty) {
const newProperty = {
name: property.name,
initializer: `[${quoteChar}${property.value}${quoteChar}]`,
}
// We need to add darkMode as the first property.
if (property.name === "darkMode") {
configObject.insertPropertyAssignment(0, newProperty)
return configObject
}
configObject.addPropertyAssignment(newProperty)
return configObject
}
if (existingProperty.isKind(SyntaxKind.PropertyAssignment)) {
const initializer = existingProperty.getInitializer()
const newValue = `${quoteChar}${property.value}${quoteChar}`
// If property is a string, change it to an array and append.
if (initializer?.isKind(SyntaxKind.StringLiteral)) {
const initializerText = initializer.getText()
initializer.replaceWithText(`[${initializerText}, ${newValue}]`)
return configObject
}
// If property is an array, append.
if (initializer?.isKind(SyntaxKind.ArrayLiteralExpression)) {
// Check if the array already contains the value.
if (
initializer
.getElements()
.map((element) => element.getText())
.includes(newValue)
) {
return configObject
}
initializer.addElement(newValue)
}
return configObject
}
return configObject
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does addTailwindConfigProperty() do?
addTailwindConfigProperty() is a function in the ui codebase, defined in packages/shadcn/src/utils/updaters/update-tailwind-config.ts.
Where is addTailwindConfigProperty() defined?
addTailwindConfigProperty() is defined in packages/shadcn/src/utils/updaters/update-tailwind-config.ts at line 124.
What calls addTailwindConfigProperty()?
addTailwindConfigProperty() is called by 1 function(s): transformTailwindConfig.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free