@@ -167,51 +167,60 @@ const contrasted = (color: string, percentage = 0.8) => {
167167const toVariables = (
168168 t : Theme & Required < ThemeColors > ,
169169) : [ string , string ] [ ] => {
170+ // DaisyUI v5 expects full oklch() values, e.g. "oklch(70% 0.18 250deg)"
170171 const toValue = ( color : string | ReturnType < typeof darken > ) => {
171172 const [ l , c , h ] = new Color ( color ) . oklch ;
172173
173- return `${ ( l * 100 ) . toFixed ( 0 ) } % ${ c . toFixed ( 2 ) } ${ ( h || 0 ) . toFixed ( 0 ) } deg` ;
174+ return `oklch( ${ ( l * 100 ) . toFixed ( 0 ) } % ${ c . toFixed ( 2 ) } ${ ( h || 0 ) . toFixed ( 0 ) } deg) ` ;
174175 } ;
175176
177+ // DaisyUI v5 variable names (--color-* prefix instead of the old v4 shorthand)
176178 const colorVariables = Object . entries ( {
177- "--p " : t [ "primary" ] ,
178- "--pc " : t [ "primary-content" ] ?? contrasted ( t [ "primary" ] ) ,
179+ "--color-primary " : t [ "primary" ] ,
180+ "--color-primary-content " : t [ "primary-content" ] ?? contrasted ( t [ "primary" ] ) ,
179181
180- "--s" : t [ "secondary" ] ,
181- "--sc" : t [ "secondary-content" ] ?? contrasted ( t [ "secondary" ] ) ,
182+ "--color-secondary" : t [ "secondary" ] ,
183+ "--color-secondary-content" :
184+ t [ "secondary-content" ] ?? contrasted ( t [ "secondary" ] ) ,
182185
183- "--a" : t [ "tertiary" ] ,
184- "--ac" : t [ "tertiary-content" ] ?? contrasted ( t [ "tertiary" ] ) ,
186+ "--color-accent" : t [ "tertiary" ] ,
187+ "--color-accent-content" :
188+ t [ "tertiary-content" ] ?? contrasted ( t [ "tertiary" ] ) ,
185189
186- "--n" : t [ "neutral" ] ,
187- "--nc" : t [ "neutral-content" ] ?? contrasted ( t [ "neutral" ] ) ,
190+ "--color-neutral" : t [ "neutral" ] ,
191+ "--color-neutral-content" :
192+ t [ "neutral-content" ] ?? contrasted ( t [ "neutral" ] ) ,
188193
189- "--b1 " : t [ "base-100" ] ,
190- "--b2 " : t [ "base-200" ] ?? darken ( t [ "base-100" ] , 0.07 ) ,
191- "--b3 " : t [ "base-300" ] ?? darken ( t [ "base-100" ] , 0.14 ) ,
192- "--bc " : t [ "base-content" ] ?? contrasted ( t [ "base-100" ] ) ,
194+ "--color-base-100 " : t [ "base-100" ] ,
195+ "--color-base-200 " : t [ "base-200" ] ?? darken ( t [ "base-100" ] , 0.07 ) ,
196+ "--color-base-300 " : t [ "base-300" ] ?? darken ( t [ "base-100" ] , 0.14 ) ,
197+ "--color-base-content " : t [ "base-content" ] ?? contrasted ( t [ "base-100" ] ) ,
193198
194- "--su" : t [ "success" ] ,
195- "--suc" : t [ "success-content" ] ?? contrasted ( t [ "success" ] ) ,
199+ "--color-success" : t [ "success" ] ,
200+ "--color-success-content" :
201+ t [ "success-content" ] ?? contrasted ( t [ "success" ] ) ,
196202
197- "--wa" : t [ "warning" ] ,
198- "--wac" : t [ "warning-content" ] ?? contrasted ( t [ "warning" ] ) ,
203+ "--color-warning" : t [ "warning" ] ,
204+ "--color-warning-content" :
205+ t [ "warning-content" ] ?? contrasted ( t [ "warning" ] ) ,
199206
200- "--er " : t [ "error" ] ,
201- "--erc " : t [ "error-content" ] ?? contrasted ( t [ "error" ] ) ,
207+ "--color-error " : t [ "error" ] ,
208+ "--color-error-content " : t [ "error-content" ] ?? contrasted ( t [ "error" ] ) ,
202209
203- "--in " : t [ "info" ] ,
204- "--inc " : t [ "info-content" ] ?? contrasted ( t [ "info" ] ) ,
210+ "--color-info " : t [ "info" ] ,
211+ "--color-info-content " : t [ "info-content" ] ?? contrasted ( t [ "info" ] ) ,
205212 } ) . map ( ( [ key , color ] ) => [ key , toValue ( color ) ] as [ string , string ] ) ;
206213
214+ // DaisyUI v5 renamed misc variables — map old interface fields to new names
207215 const miscellaneousVariables = Object . entries ( {
208- "--rounded-box" : t [ "--rounded-box" ] ,
209- "--rounded-btn" : t [ "--rounded-btn" ] ,
210- "--rounded-badge" : t [ "--rounded-badge" ] ,
216+ "--radius-box" : t [ "--rounded-box" ] , // was --rounded-box
217+ "--radius-field" : t [ "--rounded-btn" ] , // was --rounded-btn (inputs, selects)
218+ "--radius-selector" : t [ "--rounded-badge" ] , // was --rounded-badge (badges, toggles)
219+ "--border" : t [ "--border-btn" ] , // was --border-btn
220+ // animation/tab vars have no DaisyUI v5 equivalent; keep as custom props
211221 "--animation-btn" : t [ "--animation-btn" ] ,
212222 "--animation-input" : t [ "--animation-input" ] ,
213223 "--btn-focus-scale" : t [ "--btn-focus-scale" ] ,
214- "--border-btn" : t [ "--border-btn" ] ,
215224 "--tab-border" : t [ "--tab-border" ] ,
216225 "--tab-radius" : t [ "--tab-radius" ] ,
217226 } ) ;
0 commit comments