Skip to main content

Theme Configuration

The Mess package offers a dynamic and efficient way to style HTML elements and components using a combination of custom styles, breakpoints, and theme configurations. This document explains its core types, configuration, and usage with practical examples.


1. Breakpoints

Breakpoints define responsive ranges for styling elements across different screen sizes.

Type Definition

export type Breakpoint = {
min: string;
max?: string;
};

export interface Breakpoints {
[key: string]: Breakpoint;
}

Example

const breakpoints = {
sm: { min: "480px" },
lg: { min: "1024px", max: "1440px" },
};

2. Theme

Themes allow you to define reusable design tokens for colors, spacing, typography, and utility classes.

Type Definition

export interface Theme {
colors?: Record<string, string>;
fontSizes?: Record<string, string>;
paddings?: Record<string, string>;
classes?: Record<
string,
Record<string, Styles | StylesMessInternal> | Styles | StylesMessInternal
>;
utilityClasses?: any;
/* Additional properties like animations, sizes, and effects can be added */
}

Example

const theme = {
colors: {
primary: "#27A5C9",
secondary: "#FFA726",
},
fontSizes: {
sm: "12px",
lg: "18px",
},
classes: {
button: {
base: {
padding: "10px 20px",
background: "$colors.primary",
color: "white",
borderRadius: "8px",
},
},
},
};

3. Styles

Styles can be specified using either raw CSS objects or theme references.

Type Definition

export interface Styles {
base?: CSSObject;
[key: string]: CSSObject | undefined;
}

export interface StylesMessInternal {
base?: string;
[key: string]: string | undefined;
}

Examples

Using CSSObject

const styles = {
base: {
padding: "8px 10px",
background: "#27A5C9",
color: "white",
},
lg: {
padding: "12px 16px",
},
};

Using Theme References

const stylesInternal = {
base: "$classes.button.base",
lg: "$classes.button.lg",
};

4. MessConfig

The MessConfig object combines breakpoints and themes for customization.

Type Definition

export interface MessConfig extends Record<string, any> {
breakpoints?: Breakpoints;
theme: Theme;
}

Example

const config = {
breakpoints: {
sm: { min: "480px" },
lg: { min: "1024px", max: "1440px" },
},
theme: {
colors: {
primary: "#27A5C9",
secondary: "#FFA726",
},
fontSizes: {
sm: "12px",
lg: "18px",
},
},
};

5. Practical Examples

Example 1: Styling with CSSObject

<button
className={Mess({
styles: {
base: {
padding: "8px 10px",
background: "#27A5C9",
color: "white",
borderRadius: "8px",
border: "none",
},
lg: {
padding: "10px 20px",
},
},
})}
>
Button
</button>

Example 2: Using Theme Reference

<button className={Mess({ styles: "$classes.button.base" })}>
Button
</button>

Example 3: Combining Styles with Clx

<button
className={Mess({
styles: Clx(
{
base: {
padding: "8px 10px",
background: "#27A5C9",
color: "white",
borderRadius: "8px",
border: "none",
},
lg: {
padding: "10px 20px",
color: "gray",
},
},
{
lg: { color: "yellow" },
},
"$classes.button",
"lg:color-[black]"
),
})}
>
Button
</button>

Example 4: Using Custom Classes

<button
className={Mess({
customeclasses: "lg:color-[gray] bg-[red]",
})}
>
Button
</button>

Theme Keys

KeyDescription
accentColorValues for the accent-color property
animationValues for the animation property
ariaValues for the aria property
aspectRatioValues for the aspect-ratio property
backdropBlurValues for the backdropBlur plugin
backdropBrightnessValues for the backdropBrightness plugin
backdropContrastValues for the backdropContrast plugin
backdropGrayscaleValues for the backdropGrayscale plugin
backdropHueRotateValues for the backdropHueRotate plugin
backdropInvertValues for the backdropInvert plugin
backdropOpacityValues for the backdropOpacity plugin
backdropSaturateValues for the backdropSaturate plugin
backdropSepiaValues for the backdropSepia plugin
backgroundColorValues for the background-color property
backgroundImageValues for the background-image property
backgroundOpacityValues for the background-opacity property
backgroundPositionValues for the background-position property
backgroundSizeValues for the background-size property
blurValues for the blur plugin
borderColorValues for the border-color property
borderOpacityValues for the borderOpacity plugin
borderRadiusValues for the border-radius property
borderSpacingValues for the border-spacing property
borderWidthValues for the borderWidth plugin
boxShadowValues for the box-shadow property
boxShadowColorValues for the boxShadowColor plugin
brightnessValues for the brightness plugin
caretColorValues for the caret-color property
columnsValues for the columns property
classesValues for the custome-classes
containerConfiguration for the container plugin
contentValues for the content property
contrastValues for the contrast plugin
cursorValues for the cursor property
divideColorValues for the divideColor plugin
divideOpacityValues for the divideOpacity plugin
divideWidthValues for the divideWidth plugin
dropShadowValues for the dropShadow plugin
fillValues for the fill plugin
flexValues for the flex property
flexBasisValues for the flex-basis property
flexGrowValues for the flex-grow property
flexShrinkValues for the flex-shrink property
fontFamilyValues for the font-family property
fontSizeValues for the font-size property
fontWeightValues for the font-weight property
gapValues for the gap property
gradientColorStopsValues for the gradientColorStops plugin
gradientColorStopPositionsValues for the gradient-color-stop-positions property
grayscaleValues for the grayscale plugin
gridAutoColumnsValues for the grid-auto-columns property
gridAutoRowsValues for the grid-auto-rows property
gridColumnValues for the grid-column property
gridColumnEndValues for the grid-column-end property
gridColumnStartValues for the grid-column-start property
gridRowValues for the grid-row property
gridRowEndValues for the grid-row-end property
gridRowStartValues for the grid-row-start property
gridTemplateColumnsValues for the grid-template-columns property
gridTemplateRowsValues for the grid-template-rows property
heightValues for the height property
hueRotateValues for the hueRotate plugin
insetValues for the top, right, bottom, and left properties
invertValues for the invert plugin
keyframesKeyframe values used in the animation plugin
letterSpacingValues for the letter-spacing property
lineHeightValues for the line-height property
listStyleTypeValues for the list-style-type property
listStyleImageValues for the list-style-image property
marginValues for the margin property
lineClampValues for the line-clamp property
maxHeightValues for the max-height property
maxWidthValues for the max-width property
minHeightValues for the min-height property
minWidthValues for the min-width property
objectPositionValues for the object-position property
opacityValues for the opacity property
orderValues for the order property
outlineColorValues for the outline-color property
outlineOffsetValues for the outline-offset property
outlineWidthValues for the outline-width property
paddingValues for the padding property
placeholderColorValues for the placeholderColor plugin
placeholderOpacityValues for the placeholderOpacity plugin
ringColorValues for the ringColor plugin
ringOffsetColorValues for the ringOffsetColor plugin
ringOffsetWidthValues for the ringOffsetWidth plugin
ringOpacityValues for the ringOpacity plugin
ringWidthValues for the ringWidth plugin
rotateValues for the rotate plugin
saturateValues for the saturate plugin
scaleValues for the scale plugin
screensYour project's responsive breakpoints
scrollMarginValues for the scroll-margin property
scrollPaddingValues for the scroll-padding property
sepiaValues for the sepia plugin
skewValues for the skew plugin
spaceValues for the space plugin
spacingYour project's spacing scale
strokeValues for the stroke property
strokeWidthValues for the stroke-width property
supportsValues for the supports property
dataValues for the data property
textColorValues for the color property
textDecorationColorValues for the text-decoration-color property
textDecorationThicknessValues for the text-decoration-thickness property
textIndentValues for the text-indent property
textOpacityValues for the textOpacity plugin
textUnderlineOffsetValues for the text-underline-offset property
transformOriginValues for the transform-origin property
transitionDelayValues for the `transition
maxHeightValues for the max-height property
maxWidthValues for the max-width property
minHeightValues for the min-height property
minWidthValues for the min-width property
objectPositionValues for the object-position property
opacityValues for the opacity property
orderValues for the order property
outlineColorValues for the outline-color property
outlineOffsetValues for the outline-offset property
outlineWidthValues for the outline-width property
paddingValues for the padding property
placeholderColorValues for the placeholder-color property
placeholderOpacityValues for the placeholder-opacity property
ringColorValues for the ring-color property
ringOffsetColorValues for the ring-offset-color property
ringOffsetWidthValues for the ring-offset-width property
ringOpacityValues for the ring-opacity property
ringWidthValues for the ring-width property
rotateValues for the rotate property
saturateValues for the saturate property
scaleValues for the scale property
screensYour project's responsive breakpoints
scrollMarginValues for the scroll-margin property
scrollPaddingValues for the scroll-padding property
sepiaValues for the sepia property
skewValues for the skew property
spaceValues for the space property
spacingYour project's spacing scale
strokeValues for the stroke property
strokeWidthValues for the stroke-width property
supportsValues for the supports property
dataValues for the data property
textColorValues for the text-color property
textDecorationColorValues for the text-decoration-color property
textDecorationThicknessValues for the text-decoration-thickness property
textIndentValues for the text-indent property
textOpacityValues for the text-opacity property
textUnderlineOffsetValues for the text-underline-offset property
transformOriginValues for the transform-origin property
transitionDelayValues for the transition-delay property
transitionDurationValues for the transition-duration property
transitionPropertyValues for the transition-property property
transitionTimingFunctionValues for the transition-timing-function property
translateValues for the translate property
utilityClassesValues for the custome css property eg:(flex: "display: flex;")
sizeValues for the size property
widthValues for the width property
willChangeValues for the will-change property
zIndexValues for the z-index property