JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 712
  • Score
    100M100P100Q96757F
  • License MIT

Material Definition System - Think in materials, not CSS properties

Package Exports

  • @v1b3x0r/mds-core

Readme

Material Definition System (MDS) v2.0

Think in materials, not CSS properties

Status: Production Ready (v2.0) Reality: System works perfectly. Built-in materials (@mds/glass, @mds/paper) are minimal/subtle because I'm not good at visual design. You Can: Create much better-looking materials easily - see guide below!


What is MDS?

Material Definition System เป็น JavaScript library ที่ให้คุณประกาศ วัสดุ (materials) ผ่าน JSON manifests แทนการเขียน CSS properties ซ้ำๆ

Traditional CSS approach:

<div class="bg-white/10 backdrop-blur-xl border border-white/20 shadow-2xl">
  Content
</div>

MDS approach:

<div data-material="glass">
  Content
</div>

Quick Start

Installation

Local/Manual installation only (CDN coming in future release)

Download the built file and include it locally:

<script src="./dist/material-system.js"></script>

Or clone and build from source:

git clone https://github.com/v1b3x0r/material-js-concept.git
cd material-js-concept
npm install
npm run build

Basic Usage

<!DOCTYPE html>
<html>
<head>
  <script src="material-system.js"></script>
</head>
<body>
  <!-- Use built-in materials -->
  <div data-material="@mds/glass">Glass element</div>
  <div data-material="@mds/paper">Paper element</div>

  <script>
    // Load materials from CDN
    MaterialSystem.install(['@mds/glass', '@mds/paper'])
  </script>
</body>
</html>

What Works vs What Needs Your Help

What Works (System is Solid)

The core system is production-ready and battle-tested:

  • Manifest-driven architecture - JSON to CSS pipeline works perfectly
  • Theme system - Light/dark auto-switching works flawlessly
  • State management - Hover, active, focus, disabled all work
  • Material inheritance - Extend and override works as expected
  • customCSS support - ~90% CSS property coverage
  • TypeScript types - Full type safety, zero runtime errors
  • Zero dependencies - Standalone, no external CSS required
  • CDN support - Load materials from remote sources

What Needs Creative Designers (I'm Not Good at This Part)

The built-in materials need visual improvement:

  • Visual appeal: @mds/glass and @mds/paper are too subtle/minimal
  • Reason: I'm a normal nerd guy with diet coke , not a visual designer
  • Solution: You can create much better materials! See MATERIAL_GUIDE.md
  • Available: 28+ properties (opacity, blur, shadows, textures) + customCSS for advanced effects

TL;DR: Think of MDS as a "material compiler" - it compiles JSON to CSS perfectly. The sample materials I created are just boring examples. You can make way better ones!


Built-in Materials (Reference Only)

@mds/glass

Simplified glass effect - intentionally minimal to serve as a starting point

Visual: Very subtle (my design skills). Use as reference, create better ones!

@mds/paper

Matte paper with subtle noise texture

Visual: Minimal contrast (again, not my strength). You can do better!


What You Can Build (Beyond My Boring Defaults)

The built-in materials are intentionally minimal, but with 28+ properties + customCSS, you can create stunning effects:

Advanced Glass Effect

{
  "name": "dramatic-glass",
  "optics": {
    "blur": "40px",
    "saturation": "200%",
    "brightness": "130%",
    "tint": "rgba(255, 255, 255, 0.2)"
  },
  "surface": {
    "radius": "16px",
    "shadow": [
      "0 8px 32px rgba(0, 0, 0, 0.3)",
      "inset 0 1px 0 rgba(255, 255, 255, 0.5)"
    ]
  }
}

Neumorphic Material

{
  "name": "neumorphic",
  "optics": { "opacity": 1 },
  "surface": { "radius": "20px" },
  "customCSS": {
    "background": "linear-gradient(145deg, #e6e6e6, #ffffff)",
    "box-shadow": "20px 20px 60px #d9d9d9, -20px -20px 60px #ffffff"
  }
}

Animated Gradient

{
  "name": "gradient-animated",
  "surface": { "radius": "12px" },
  "customCSS": {
    "background": "linear-gradient(270deg, #ff0080, #7928ca, #0070f3)",
    "background-size": "600% 600%",
    "animation": "gradient 8s ease infinite"
  }
}

See MATERIAL_GUIDE.md for 7 complete examples and all 28+ properties.


Creating Custom Materials

See MATERIAL_GUIDE.md for comprehensive documentation on:

  • All 28+ available properties
  • Complete examples (beginner to advanced)
  • Validation rules and common mistakes
  • customCSS field for CSS experts
  • Theme and state variations

Quick example:

{
  "name": "my-material",
  "optics": {
    "opacity": 0.95,
    "tint": "#ffffff"
  },
  "surface": {
    "radius": "12px",
    "border": "1px solid rgba(255, 255, 255, 0.2)",
    "shadow": "0 8px 32px rgba(0, 0, 0, 0.1)"
  },
  "states": {
    "hover": {
      "optics": { "opacity": 1 }
    }
  }
}

API Reference

MaterialSystem.install(names, options?)

Load materials from CDN.

// Single material
await MaterialSystem.install('@mds/glass')

// Multiple materials
await MaterialSystem.install(['@mds/glass', '@mds/paper'])

// Custom CDN
await MaterialSystem.install('@mds/glass', {
  cdn: 'https://custom-cdn.com'
})

Note: Official CDN not yet available. To use install(), you need to:

  1. Host manifests on your own server/CDN
  2. Pass custom CDN URL via options parameter

MaterialSystem.register(name, material)

Register material from JavaScript object.

MaterialSystem.register('custom', {
  optics: { tint: '#ff0000' },
  surface: { radius: '8px' }
})

MaterialSystem.registerFromManifest(manifest)

Register from JSON manifest.

const manifest = await fetch('./my-material.mdm.json').then(r => r.json())
await MaterialSystem.registerFromManifest(manifest)

MaterialSystem.extend(name, baseName, overrides)

Extend existing material.

MaterialSystem.extend('glass-blue', '@mds/glass', {
  optics: { tint: '#0066ff' }
})

MaterialSystem.setTheme(theme)

Set theme mode.

MaterialSystem.setTheme('dark')   // Force dark
MaterialSystem.setTheme('light')  // Force light
MaterialSystem.setTheme('auto')   // Follow system preference

MaterialSystem.getTheme()

Get current resolved theme ('light' or 'dark').

const theme = MaterialSystem.getTheme()  // 'light' | 'dark'

MaterialSystem.getThemeMode()

Get theme mode including 'auto'.

const mode = MaterialSystem.getThemeMode()  // 'light' | 'dark' | 'auto'

Architecture

┌─────────────────┐
│  JSON Manifest  │  ← Material definition
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│  MaterialSystem │  ← Runtime engine
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│   DOM Element   │  ← data-material="name"
└─────────────────┘

File Structure

material-js-concept/
├── src/                     # Source code (TypeScript)
│   ├── core/               # Core system
│   │   ├── types.ts        # Type definitions
│   │   ├── registry.ts     # Material registry
│   │   └── utils.ts        # Utilities
│   ├── mappers/            # Property mappers
│   │   ├── optics.ts       # Visual tinting
│   │   ├── surface.ts      # Texture/geometry
│   │   └── behavior.ts     # Interactions
│   ├── theme/              # Theme management
│   ├── states/             # State machine
│   ├── physics/            # Physics (drag, spring)
│   └── index.ts            # Main entry
├── manifests/              # Material manifests
│   └── @mds/
│       ├── glass.mdm.json
│       └── paper.mdm.json
├── dist/                   # Built files
│   └── material-system.js  # Standalone bundle
├── index.html              # Demo page
└── MATERIAL_GUIDE.md       # Creation guide

Philosophy

Think in Materials, Not Properties

Traditional CSS thinking:

  • "I need backdrop-filter: blur(20px)"
  • "Add opacity: 0.8"
  • "Box-shadow: 0 8px 32px..."

MDS thinking:

  • "This is glass"
  • "This is paper"
  • "This should feel like metal"

Separation of Concerns

Layer Responsibility Example
HTML Structure <div>, <button>
CSS/Tailwind Layout/Typography px-4, flex, text-lg
MDS Material Properties data-material="glass"

Do NOT mix:

<!-- ❌ Bad - visual properties in CSS -->
<div class="bg-white/10 backdrop-blur-xl" data-material="glass">

<!-- ✅ Good - clean separation -->
<div class="px-4 py-2 rounded-xl" data-material="glass">

Advanced Usage

Custom CSS for Experts

For CSS properties not covered by optics/surface/behavior, use customCSS:

{
  "name": "advanced-material",
  "optics": { "tint": "#fff" },
  "customCSS": {
    "clip-path": "polygon(0 0, 100% 0, 100% 95%, 50% 100%, 0 95%)",
    "mix-blend-mode": "multiply",
    "filter": "drop-shadow(0 0 10px rgba(0,0,0,0.5))"
  }
}

Coverage: ~90% of CSS properties (vs ~40-50% without customCSS)

Limitations: No pseudo-elements, @keyframes, or dynamic values

See MATERIAL_GUIDE.md for full documentation.


Built-in Material Limitations (Not System Limitations)

What Built-in Materials What You Can Build
Visual contrast Too subtle (my fault) High contrast with proper opacity/shadows
Dramatic effects Minimal (boring defaults) Unlimited with 28+ properties
Advanced CSS Basic only (@mds/glass) ~90% CSS coverage with customCSS
Neumorphism Not included Easy with customCSS
Animated gradients Not included Easy with customCSS + keyframes
Dynamic lighting CSS limitation* Requires WebGL (not MDS's job)
Mouse tracking CSS limitation* Requires custom JS (not MDS's job)

Key point: The system supports advanced effects. My sample materials just happen to be boring.

* These are CSS/DOM limitations, not MDS limitations. MDS does what CSS can do.


FAQ

Why are @mds/glass and @mds/paper so hard to see?

Honest answer: I'm a systems engineer, not a visual designer. I focused on making the architecture solid, but my design skills are... not great.

The good news: You don't have to use my materials! The system supports:

  • 28+ visual properties: opacity, tint, blur, saturation, brightness, contrast, shadows, textures, borders, radius
  • customCSS: ANY CSS property not covered by the core 28 properties
  • Full state control: hover, active, focus, disabled - each can have different styles
  • Theme variants: Automatic light/dark mode with custom overrides

Check MATERIAL_GUIDE.md to create materials that look way better than mine.

Is this production-ready?

System: Yes

  • Architecture is solid (manifest to runtime to DOM)
  • TypeScript types are correct and complete
  • Theme system works flawlessly
  • State management tested
  • Zero known bugs

Built-in materials: Use for reference only, create your own for production

Think of it like: React ships with boring default styles, but you build beautiful UIs with it. Same here - MDS is the compiler, you bring the creativity.

Can I use this in my project right now?

Yes! As long as you:

  1. Create your own materials (don't use @mds/glass/@mds/paper as-is)
  2. Test on your target browsers (Chrome/Edge 90+, Firefox 88+, Safari 14+)
  3. Follow the MATERIAL_GUIDE.md for best practices

The system is stable. Just the sample materials are underwhelming.


Browser Support

  • Chrome/Edge 90+
  • Firefox 88+
  • Safari 14+

Required CSS features:

  • backdrop-filter (glass materials)
  • CSS variables
  • MutationObserver (dynamic content)

Contributing

I Need Help With Visual Design

The system architecture is solid, but I'm terrible at making things look good. If you're a designer or have good visual taste:

Share your materials:

  • Create beautiful materials and PR them to /manifests/@community/
  • Show what's possible with the 28+ properties + customCSS
  • Help others learn by example

Improve the defaults:

  • Make @mds/glass and @mds/paper actually visible and usable
  • Create variants (frosted glass, glossy paper, etc.)
  • Better shadows, better contrast, better everything

Create examples:

  • Advanced customCSS usage
  • Neumorphic designs
  • Animated materials
  • Theme-aware materials

Code Contributions

  • Bug fixes: Always welcome
  • New features: Open an issue first to discuss
  • Performance improvements: Appreciated
  • Documentation: Help make it clearer

The architecture is done. Now it needs creative people to make beautiful things with it!


Documentation

  • MATERIAL_GUIDE.md - How to create materials (complete reference)
  • CLAUDE.md - AI assistant context (project state, decisions, future work)

License

MIT


Acknowledgments

Built with honesty about limitations. Materials are subtle/barely visible because CSS cannot achieve true photorealistic glass without WebGL/shaders.

Reality check: If you need production-ready materials, consider:

  • Three.js (WebGL-based)
  • Babylon.js (PBR materials)
  • Traditional CSS with more contrast

MDS is for learning and experimentation, not production deployment (yet).