You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -104,7 +104,6 @@ Global CSS blocks are optimized by:
104
104
-**Removing comments**: `/* comment */` is stripped
105
105
-**Minifying whitespace**: Multiple spaces become single spaces
106
106
-**Removing semicolons**: Last property in a block doesn't need semicolon
107
-
-**Optimizing selectors**: Redundant selectors are merged
108
107
109
108
```css
110
109
/* Before optimization */
@@ -155,28 +154,14 @@ Values are converted to their most appropriate units:
155
154
Numeric values are automatically interpreted as pixel units, while string-based values with explicit units (e.g., rem, %) are preserved for accurate rendering.
156
155
157
156
```
158
-
// Numbers without units are treated as pixels
159
-
<Box w={16} /> // width: 16px
157
+
// Numbers without units are treated as pixels (multiplied by 4)
158
+
<Box w={16} /> // width: 64px
160
159
161
160
// Strings with units are preserved
162
161
<Box w="16rem" /> // width: 16rem
163
162
<Box w="100%" /> // width: 100%
164
163
```
165
164
166
-
### **Mathematical Optimization**
167
-
168
-
Mathematical expressions are optimized to their most efficient form:
169
-
170
-
```
171
-
// Before
172
-
<Box w="calc(100% - 32px)" />
173
-
<Box w="calc(50% + 16px)" />
174
-
175
-
// After (optimized)
176
-
<Box w="calc(100% - 2rem)" /> // px converted to rem for better scalability
177
-
<Box w="calc(50% + 1rem)" /> // px converted to rem for better scalability
178
-
```
179
-
180
165
### **Zero Value Optimization**
181
166
182
167
Zero values are optimized:
@@ -207,24 +192,6 @@ Identical style rules across multiple components are automatically merged into a
207
192
// .red-white{background:red;color:white}
208
193
```
209
194
210
-
### **Property Deduplication**
211
-
212
-
Duplicate CSS properties within the same rule are automatically removed, keeping only the last valid declaration for consistency and cleaner output.
213
-
214
-
```
215
-
// Input
216
-
<Box
217
-
style={{
218
-
margin: '0',
219
-
padding: '0',
220
-
margin: '0', // duplicate
221
-
}}
222
-
/>
223
-
224
-
// Output: Duplicate margin removed
225
-
<Box style={{ margin: '0', padding: '0' }} />
226
-
```
227
-
228
195
### **Advantages**
229
196
230
197
Devup UI offers complete flexibility in how you implement and optimize styles — while maintaining measurable performance gains.
Copy file name to clipboardExpand all lines: apps/landing/src/app/(detail)/docs/core-concepts/type-inference-system/page.mdx
+12-42Lines changed: 12 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,58 +12,28 @@ Unlike traditional CSS-in-JS libraries, Devup UI **derives types directly from C
12
12
13
13
## How It Works
14
14
15
-
The type inference process consists of four main steps:
15
+
Devup UI uses the **csstype** package to automatically generate types for CSS properties. Instead of manually defining types, Devup UI reads the standard CSS definitions from csstype and uses them directly.
16
16
17
-
1.**Parsing** – analyzes JSX/TSX code
18
-
2.**Property Lookup** – checks against the CSS property map
Devup UI reads all CSS property definitions from the **csstype** package, which contains the official CSS standards. This includes both regular properties (like `width`, `color`) and shorthand properties (like `margin`, `padding`).
23
20
24
-
All CSS properties are defined in a Rust-based mapping table.
When you use CSS states like `:hover` or `:focus`, Devup UI automatically converts them into props you can use. For example, `:hover` becomes `_hover` so you can write `<Box _hover={{ bg: 'red' }} />`.
35
24
36
-
```
25
+
When `csstype` is updated with new CSS standards, Devup UI automatically gets these updates without needing a library update.
37
26
38
-
### 2. Type Generation
27
+
### 3. Catching Mistakes Early
39
28
40
-
TypeScript types are automatically derived from CSS property names and value patterns.
41
-
42
-
It supports various value types — such as lengths, colors, and percentages — and
43
-
44
-
ensures **type-safe responsive arrays** for breakpoint-based styles.
45
-
46
-
```tsx
47
-
<Boxw={[100, 200, 300]} />
48
-
```
49
-
50
-
### 3. Special Property Handling
51
-
52
-
Certain properties are excluded from inference, such as React-specific or HTML attributes.
TypeScript checks your CSS properties while you're coding. If you try to use an invalid property or value, you'll get an error right away instead of discovering it later.
60
30
61
31
## Advantages
62
32
63
-
Devup UI’s type inference system provides several key benefits:
33
+
Devup UI's type inference system provides several key benefits:
64
34
65
-
-**Automatic updates** – New CSS properties are supported immediately when standards evolve, without requiring library updates.
66
-
-**Type safety** – All properties and values are strictly typed, preventing invalid or misspelled declarations at compile time.
67
-
-**Extensibility** – Experimental or custom CSS features can be easily extended within the system.
35
+
-**Automatic updates** – New CSS properties are supported immediately when the csstype package is updated. Simply update the package without requiring devup-ui library updates.
36
+
-**Type safety** – All properties and values are strictly typed based on CSS standards, preventing invalid or misspelled declarations at compile time.
37
+
-**Standards compliance** – Types are always aligned with official CSS specifications, ensuring accuracy and consistency across all CSS standards.
68
38
69
39
This type inference system is automatic, reliable, and future-ready, allowing developers to focus on design and logic rather than manual type management.
0 commit comments