@@ -247,7 +247,10 @@ export default defineConfig({
247247 },
248248 variables: {
249249 1: "palette.simple.white",
250- 2: "gradients.white-green.primary",
250+ 2: "gradients.white-green.primary", //Reference the color name directly.
251+ },
252+ settings: {
253+ variantNameOnly: true,
251254 },
252255 },
253256 },
@@ -263,12 +266,35 @@ export default defineConfig({
263266 1: "palette.another.yellow",
264267 2: "palette.another.cyan",
265268 },
269+ settings: {
270+ variantNameOnly: true,
271+ },
266272 },
267273 },
268274 settings: {
269275 condition: "@media (prefers-color-scheme: dark)",
270276 },
271277 },
278+ pink: {
279+ value: {
280+ background: {
281+ value: {
282+ primary: "var(--1)",
283+ secondary: "var(--2)",
284+ },
285+ variables: {
286+ 1: "palette.simple.red",
287+ 2: "palette.simple.violet",
288+ },
289+ settings: {
290+ variantNameOnly: true,
291+ },
292+ },
293+ },
294+ settings: {
295+ condition: ".ThemePink",
296+ },
297+ },
272298 },
273299 },
274300});
@@ -325,7 +351,10 @@ export default defineConfig({
325351 },
326352 variables: {
327353 1 : " palette.simple.white" ,
328- 2 : " gradients.white-green" , // Reference the color name directly.
354+ 2 : " gradients.white-green.primary" , // Reference the color name directly.
355+ },
356+ settings: {
357+ variantNameOnly: true ,
329358 },
330359 },
331360 },
@@ -341,12 +370,35 @@ export default defineConfig({
341370 1 : " palette.another.yellow" ,
342371 2 : " palette.another.cyan" ,
343372 },
373+ settings: {
374+ variantNameOnly: true ,
375+ },
344376 },
345377 },
346378 settings: {
347379 condition: " @media (prefers-color-scheme: dark)" ,
348380 },
349381 },
382+ pink: {
383+ value: {
384+ background: {
385+ value: {
386+ primary: " var(--1)" ,
387+ secondary: " var(--2)" ,
388+ },
389+ variables: {
390+ 1 : " palette.simple.red" ,
391+ 2 : " palette.simple.violet" ,
392+ },
393+ settings: {
394+ variantNameOnly: true ,
395+ },
396+ },
397+ },
398+ settings: {
399+ condition: " .ThemePink" ,
400+ },
401+ },
350402 },
351403 },
352404});
@@ -366,31 +418,56 @@ This will generate the following CSS :
366418 --palette-simple-blue : oklch(45.201% 0.31321 264.05202 );
367419 --palette-simple-violet : oklch(70% 0.2 270 );
368420 --palette-simple-red : oklch(62.796% 0.25768 29.23388 );
421+ /* another */
369422 .Another {
370- /* another */
371423 --palette-another-yellow : oklch(96.798% 0.21101 109.76924 );
372424 --palette-another-cyan : oklch(90.54% 0.15455 194.76896 );
373425 }
374- /* Gradients */
426+ /* Gradients */
427+ /* white-green */
375428 --gradients-white-green-primary: linear-gradient(
376429 to right,
377430 var(--palette-simple-white),
378431 var(--palette-simple-green)
379432 );
380- /* Themes */
433+ /* Themes */
381434 /* Theme: light */
382435 /* background */
436+ --primary: var(--palette-simple-white);
437+ --secondary: var(--gradients-white-green-primary);
438+ /* Theme: dark */
383439 @media (prefers-color-scheme: dark) {
384- /* Theme: dark */
385440 /* background */
386- --theme-dark-background-primary: var(--palette-another-yellow);
387- --theme-dark-background-secondary: var(--palette-another-cyan);
441+ --primary: var(--palette-another-yellow);
442+ --secondary: var(--palette-another-cyan);
443+ }
444+ /* Theme: pink */
445+ .ThemePink {
446+ /* background */
447+ --primary : var (--palette-simple-red );
448+ --secondary : var (--palette-simple-violet );
388449 }
389450}
390451```
391452
392453<!-- /md:generate -->
393454
455+ #### Condition
456+
457+ You can conditionnally apply colors, gradients or themes by setting the ` condition `
458+ property to a selector or media query. Your variables will be wrapped within the
459+ condition.
460+
461+ #### Theme: Variant Name Only
462+
463+ When working with themes, you can choose to only include the variant name in the CSS
464+ variable name by setting ` variantNameOnly: true ` in the color definition settings. This is
465+ usually used in combination with ` condition ` to conditionnally apply themes.
466+
467+ - Default: ` --theme-${themeName}-${colorName}-${variantName} `
468+ - VariantOnly Name: ` --${variantName} `
469+ - Path : ` theme.${themeName}.${colorName}.${variantName} `
470+
394471### Spacing
395472
396473Define custom spacing scale, that can be referenced for other types, such as primitives.
0 commit comments