@_linked/css

中文文档
0.3.3发布于 2026/10/28MIT零依赖构建来源已验证近 30 天下载 2478

CSS variables, utilities, and theme defaults for the Linked framework

原始使用文档
文档目录10 节
  1. Files
  2. Recommended import order
  3. Naming systems
  4. State-first / generic tokens
  5. Component-first / specific tokens
  6. Why both
  7. Known gap
  8. Tailwind v4 peer dependency
  9. Future ideas
  10. License

@_linked/css

CSS variables, utilities, and theme defaults for the Linked framework.

This is a CSS-only asset package — no JavaScript, no build step. It ships the design-token vocabulary and the Tailwind v4 theme primitives that all @_linked/* component packages and Linked-based apps consume.


Files

FilePurpose
preflight.cssTailwind-derived preflight with :not() exclusions to preserve inline element styles (<span>, <a>, <b>, <em>, <code>, etc.). Apps using @_linked/css typically import this instead of the bundled Tailwind preflight via the split-import pattern (see below).
package.cssTailwind v4 @theme registration of --spacing: 0.25rem. Import this from any module CSS file that uses Tailwind v4's --spacing(N) function.
theme-defaults.cssComponent-first semantic tokens (--card-bg, --popover-bg, --modal-shadow, etc.) for ~15 Linked component groups + Tailwind @theme static palette + @source inline() safelists. Import this from your app theme.
utilities.cssTailwind v4 @utility mixins for layout primitives — surface-base, card-base, modal-base, popover-base, section-base, element-base. Import this from your app theme alongside theme-defaults.css.
docs/styling-and-themes.mdLong-form theming guide for app authors.

In your app's main theme file (e.g. src/css/theme.css):

/* 1. Tailwind v4 layers — split-import pattern to substitute the LINCD preflight */
@layer theme, base, components, utilities;
@import 'tailwindcss/theme.css' layer(theme);
@import '@_linked/css/preflight.css';            /* substitutes Tailwind's bundled preflight */
@import 'tailwindcss/utilities.css' layer(utilities);

/* 2. Tailwind config (provides Linked component content paths) */
@config "@_linked/cli/tailwind.config.js";

/* 3. @_linked/css theme defaults + utility mixins */
@import '@_linked/css/theme-defaults.css';
@import '@_linked/css/utilities.css';

/* 4. Your app-specific overrides — brand palette, page-level surface tokens, dark mode */
@theme static {
  --color-primary-500: #116d8d; /* example brand color */
  /* ... */
}

:root {
  --bg-page: var(--color-gray-50);
  --bg-card: var(--color-white);
  /* ... */
}

Why the split-import? The shorthand @import 'tailwindcss'; brings in Tailwind's bundled preflight, which uses a bare *, ::before, ::after reset that wipes inline element styles (<b>, <em>, <span>, <a>, <code>, etc.). For app shells rendering rich content (chatbot messages, ontology descriptions, markdown-derived text), that reset is too aggressive. @_linked/css/preflight.css is the same Tailwind preflight minus the inline-element wipe, exposed via :not() exclusions on the universal selector. Importing the layers separately lets us substitute the LINCD-friendly preflight in.

In a Linked component package's module CSS (e.g. Toggle.module.css):

@import './helpers/mixins.css';
@import '@_linked/css/package.css';

.Root {
  padding: var(--toggle-padding-y, --spacing(1)) var(--toggle-padding-x, --spacing(2));
  /* ... */
}

Component packages typically only need package.css because the consuming app provides the full theme. package.css is intentionally minimal so it doesn't inflate component bundles.


Naming systems

@_linked/css uses two intentional naming layers, both Linked-style (neither is Tailwind-native):

State-first / generic tokens

Examples: --bg-card, --bg-modal, --bg-page, --spacing-card, --shadow-card, --radius-modal.

These are page/app-surface tokens, used by utilities.css's @utility mixins. They align with Tailwind utility class naming (bg-*, shadow-*, etc.). Defined by the consuming app, typically in the app's main theme file.

Component-first / specific tokens

Examples: --card-bg, --popover-bg, --modal-bg, --surface-bg, --button-primary-bg, --field-border.

These are component primitives. Components reference state tokens for their defaults but expose component-specific tokens for fine-grained overrides. Defined in theme-defaults.css.

Why both

Components fall through layers:

.Toggle {
  background: var(--toggle-bg, var(--control-bg, var(--bg-active)));
  /*          └─ component-specific  └─ component-group  └─ state */
}

Apps can override at any layer. The state-first layer keeps Linked variable naming aligned with Tailwind's utility conventions; the component-first layer gives component authors precise control points.

Known gap

utilities.css's @utility mixins reference state-first tokens (--bg-card, --bg-modal, --spacing-card, etc.) that are not defined in theme-defaults.css. The consuming app must define them. Both CN's src/scss/theme.css and the @_linked/cli app template do this. If you import utilities.css without app-defined state tokens, the @utility mixins resolve to empty values silently. See follow-up ideation: docs/ideas/014-promote-cn-css-tokens-to-linked-css.md (in the create_now workspace).


Tailwind v4 peer dependency

This package declares tailwindcss: "^4" as a peerDependency. Linked apps are built around Tailwind v4 — theme-defaults.css uses @theme, @theme static, @source inline(...), and --spacing(); utilities.css uses @utility. None of these directives work without Tailwind v4. Install Tailwind v4 in your app:

yarn add tailwindcss@^4 @tailwindcss/postcss@^4

(Linked-CLI-based apps already ship with Tailwind v4 transitively via @_linked/cli.)


Future ideas

  • --focus-* / --disabled-* token namespace — @_linked/primitives ships PostCSS mixins (@define-mixin focus, @define-mixin disabled) but no semantic tokens for these states beyond --control-outline-*. Adding --focus-bg, --focus-ring-color, --disabled-opacity etc. as a framework-default would let component authors share a consistent focus/disabled look without per-component re-declaration.
  • Dark mode framework defaults — currently apps own [data-theme='dark'] blocks for every token. Shipping a default dark palette in theme-defaults.css would reduce duplication; apps could override only brand-specific dark values. See ideation 013 D11 (deferred).
  • Token catalogue / search UI — interactive doc that lists every shipped token with live example. Could be auto-generated from theme-defaults.css.
  • Reconcile --bg-* (state-first) with --*-bg (component-first) — long-term, document one as deprecated or unify the naming. Tracked in follow-up 014.

License

MIT.

版本与发布记录

@_linked/css 共发布 14 个版本,首次发布于 2026/04/06;过去 12 个月发布了 14 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.3latest2026/10/2810 天前
0.3.22026/10/2513 天前
0.3.12026/09/271 个月前
0.3.02026/09/111 个月前
0.2.0-next.20260709142816next2026/07/093 个月前
0.2.0-next.202606261503462026/06/264 个月前

关于 @_linked/css 的常见问题

@_linked/css 是什么?

CSS variables, utilities, and theme defaults for the Linked framework

如何安装 @_linked/css?

在项目目录运行 npm install @_linked/css,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:tailwindcss(^4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@_linked/css 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/_linked__css 是否存在。

@_linked/css 可以商用吗?

@_linked/css 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@_linked/css 的下载量有多少?

根据 npm 官方下载统计,@_linked/css 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,478 次,日均约 83 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@_linked/css 还在维护吗?

最新版本 0.3.3 发布于 2026/10/28(10 天前);至今共发布 14 个版本,其中过去 12 个月发布了 14 个;首次发布于 2026/04/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。