@@ -146,7 +146,11 @@ export interface TastyConfig {
146146 /**
147147 * Global CSS @property definitions for custom properties.
148148 * Keys use tasty token syntax ($name for properties, #name for colors).
149- * Properties are only injected when the component using them is rendered.
149+ *
150+ * Tasty ships with `DEFAULT_PROPERTIES` (e.g. `$gap`, `$radius`, `#white`,
151+ * `#black`, `#clear`, `#border`, etc.) that are always included.
152+ * Properties you specify here are merged on top, so you can override any
153+ * default by using the same key.
150154 *
151155 * For color tokens (#name), `syntax: '<color>'` is auto-set and
152156 * `initialValue` defaults to `'transparent'` if not specified.
@@ -158,6 +162,8 @@ export interface TastyConfig {
158162 * '$rotation': { syntax: '<angle>', initialValue: '0deg' },
159163 * '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
160164 * '#accent': { initialValue: 'purple' }, // syntax: '<color>' auto-set
165+ * // Override a default property:
166+ * '$gap': { syntax: '<length>', inherits: true, initialValue: '8px' },
161167 * },
162168 * });
163169 *
@@ -363,14 +369,14 @@ let globalRecipes: Record<string, RecipeStyles> | null = null;
363369let globalConfigTokens : ConfigTokens | null = null ;
364370
365371/**
366- * Internal properties required by tasty core features .
367- * These are always injected when styles are first generated .
372+ * Default properties shipped with tasty.
373+ * These are always included unless explicitly overridden via `configure({ properties })` .
368374 * Keys use tasty token syntax (#name for colors, $name for other properties).
369375 *
370376 * For properties with CSS @property-compatible types (length, time, number, color),
371377 * an `initialValue` is provided so the property works even without a project-level token.
372378 */
373- export const INTERNAL_PROPERTIES : Record < string , PropertyDefinition > = {
379+ export const DEFAULT_PROPERTIES : Record < string , PropertyDefinition > = {
374380 // Used by dual-fill feature to enable CSS transitions on the second fill color
375381 '#tasty-second-fill' : {
376382 inherits : false ,
@@ -390,6 +396,16 @@ export const INTERNAL_PROPERTIES: Record<string, PropertyDefinition> = {
390396 inherits : true ,
391397 initialValue : 'rgb(0 0 0)' ,
392398 } ,
399+ // Shorthand for transparent
400+ '#clear' : {
401+ inherits : true ,
402+ initialValue : 'transparent' ,
403+ } ,
404+ // Default border color
405+ '#border' : {
406+ inherits : true ,
407+ initialValue : 'rgb(0 0 0)' ,
408+ } ,
393409
394410 // ---- Core design tokens used by style handlers ----
395411 // These provide sensible defaults so tasty works standalone without a design system.
@@ -530,19 +546,11 @@ export function markStylesGenerated(): void {
530546
531547 const injector = getGlobalInjector ( ) ;
532548
533- // Inject internal properties required by tasty core features
534- for ( const [ token , definition ] of Object . entries ( INTERNAL_PROPERTIES ) ) {
549+ // Inject all properties (defaults merged with user-configured overrides)
550+ for ( const [ token , definition ] of Object . entries ( getEffectiveProperties ( ) ) ) {
535551 injector . property ( token , definition ) ;
536552 }
537553
538- // Inject global properties if any were configured
539- // Properties are permanent and only need to be injected once
540- if ( globalProperties && Object . keys ( globalProperties ) . length > 0 ) {
541- for ( const [ token , definition ] of Object . entries ( globalProperties ) ) {
542- injector . property ( token , definition ) ;
543- }
544- }
545-
546554 // Inject global @font -face rules (eagerly — fonts should be available before render)
547555 if ( globalFontFace && Object . keys ( globalFontFace ) . length > 0 ) {
548556 for ( const [ family , input ] of Object . entries ( globalFontFace ) ) {
@@ -667,6 +675,15 @@ function setGlobalProperties(
667675 globalProperties = properties ;
668676}
669677
678+ /**
679+ * Get the effective properties: DEFAULT_PROPERTIES merged with user-configured
680+ * properties. User properties override defaults with matching keys.
681+ */
682+ export function getEffectiveProperties ( ) : Record < string , PropertyDefinition > {
683+ if ( ! globalProperties ) return DEFAULT_PROPERTIES ;
684+ return { ...DEFAULT_PROPERTIES , ...globalProperties } ;
685+ }
686+
670687// ============================================================================
671688// Global Font Face Management
672689// ============================================================================
0 commit comments