ECMAScript.Style 0.10.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ECMAScript.Style --version 0.10.0
                    
NuGet\Install-Package ECMAScript.Style -Version 0.10.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ECMAScript.Style" Version="0.10.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ECMAScript.Style" Version="0.10.0" />
                    
Directory.Packages.props
<PackageReference Include="ECMAScript.Style" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ECMAScript.Style --version 0.10.0
                    
#r "nuget: ECMAScript.Style, 0.10.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ECMAScript.Style@0.10.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ECMAScript.Style&version=0.10.0
                    
Install as a Cake Addin
#tool nuget:?package=ECMAScript.Style&version=0.10.0
                    
Install as a Cake Tool

ECMAScript.Style

定位:面向 Jazor ECMAScript 模块的强类型、确定性 CSS-in-JS binding。

ECMAScript.Style 将结构化 C# 值转换为标准 style.mjs runtime 模块。它保持普通 ECMAScript import、Razor-to-Vue 互操作、基于内容的稳定命名、隔离 registry、Shadow DOM 所有权、SSR snapshot、CSP nonce 与幂等 hydration。

安装

<ItemGroup>
  <PackageReference Include="ECMAScript.Style" Version="0.9.0" />
</ItemGroup>

该包依赖同版本 Jazor 进行编译和产物发射,但不安装 Razor hook、CSS 专用 MSBuild target、Vue adapter 或 compiler 分支。只有调用 css API 才会注册样式。

编写方式

通过小写静态类 css 创建规则与 class name:

using ECMAScript.Style;
using static ECMAScript.Style.css;

var actionClass = style(new CssRule
{
    Display = inlineFlex,
    Gap = rem(0.5),
    AlignItems = keyword("center")
});

公开 API 使用类型化长度、颜色、时间、display、selector 与 at-rule 值域。已存在的强类型值应直接使用;raw(...) 只用于尚未建模且调用方明确承担语义的 CSS 语法。

现代尺寸与锚点定位同样使用专用值域,不需要把 anchor-size()calc-size() 写回原始字符串:

var cardAnchor = anchorName("--card");

var popoverClass = style(new CssRule
{
    AnchorName = cardAnchor,
    PositionAnchor = cardAnchor,
    Width = calcSize(minContent, size + rem(1)),
    Top = anchor(cardAnchor, anchorBottom, rem(0.5)),
    MarginTop = anchorSize(cardAnchor, anchorBlock)
});

CssSizingValueCssAnchorPositionValueCssInsetValue 与锚点声明值域彼此独立,因此宽度、定位边、简写和锚点名称不会因更新 WebRef grammar 而退化为通用 CssValue

确定性与 hydration

规则名称从内容稳定推导,注册顺序、嵌套规则与 keyframe 输出保持可预测。documentShadowRoot、detached 提取和 hydration 共享同一 runtime contract;SSR 只传递应用明确拥有的 snapshot 和 nonce 信息,不隐式建立全局状态。

产物与验证

JazorMode=debug 会随应用产物物化 style.mjs;release 由 Jazor.Emit 与 Netpack 处理。运行相关回归:

dotnet test src/ECMAScript.Style.Test/ECMAScript.Style.Test.csproj

边界

  • 本包不负责 Razor Source Generator、Vue 组件 lowering 或 CSS 文件管理。
  • 运行时样式值必须保持已声明的 C# domain,不以 object? 作为公开 catch-all。
  • 具体 CSS 属性与生成输入以源码、WebIDL inventory 和测试为准,README 不维护逐项属性清单。

相关文档

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.0

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ECMAScript.Style:

Package Downloads
Jazor.Admin

Jazor admin-shell contracts and native RazorVue components.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.11.0 0 8/11/2026
0.10.0 0 8/11/2026
0.9.0 0 8/11/2026
0.8.3 31 8/11/2026
0.8.2 33 8/11/2026
0.7.0 48 8/10/2026
0.6.0 51 8/10/2026
0.5.0 46 8/9/2026
0.4.0 48 8/9/2026
0.3.4 52 8/9/2026
0.3.3 50 8/7/2026
0.3.2 54 8/6/2026
0.1.48 55 8/5/2026
0.1.47 49 8/5/2026
0.1.46 49 8/5/2026
0.1.45 46 8/5/2026
0.1.43 75 8/4/2026
0.1.42 97 8/4/2026
0.1.41 98 8/4/2026
0.1.40 98 8/3/2026
Loading failed