@frontile/theme

中文文档
0.18.9发布于 2026/11/14MITTypeScriptCommonJS近 30 天下载 4912

Component Library for Ember Octane apps: Theme

原始使用文档
文档目录8 节
  1. @frontile/theme
  2. Compatibility
  3. Installation
  4. Styles
  5. Color Configuration
  6. Customizing On-Colors
  7. Documentation
  8. License

@frontile/theme

Component Library for Ember Octane apps: Theme

Compatibility

  • Ember.js v3.16 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

ember install @frontile/theme

Styles

Tailwind CSS v3

// tailwind.config.js

const { frontile, safelist } = require('@frontile/theme/plugin');

module.exports = {
  content: [
    './app/**/*.{html,js,ts,hbs,gts,gjs}',
    './node_modules/@frontile/theme/dist/**/*.js',
  ],
  safelist: [
    ...safelist,
  ],
  darkMode: "class",
  theme: {
    extend: {},
  },
  plugins: [frontile()],
  // ...
};

Tailwind CSS v4

Using Default Theme

For the default theme, add this to your app/styles/app.css:

@import "tailwindcss" source("../../");
@plugin "@frontile/theme/plugin/default";
@source '../../node_modules/@frontile';
Customizing Frontile Theme

To customize the frontile theme, create a file in the root of your project named frontile.js with the following content:

const { frontile } = require('@frontile/theme/plugin');

module.exports = frontile({ /* your config */ });

Then update your app/styles/app.css to use the custom configuration:

@import "tailwindcss" source("../../");
@plugin "./../../frontile.js";
@source '../../node_modules/@frontile';

Color Configuration

You can customize Frontile colors in two ways:

Configure colors in your frontile.js file. This approach automatically generates "on-" colors for optimal text contrast:

const { frontile } = require('@frontile/theme/plugin');

module.exports = frontile({
  themes: {
    light: {
      colors: {
        primary: {
          subtle: '#3b82f6',
          DEFAULT: '#2563eb',
          strong: '#1d4ed8',
        }
      }
    },
    dark: {
      colors: {
        primary: {
          subtle: '#60a5fa',
          DEFAULT: '#3b82f6',
          strong: '#2563eb',
        }
      }
    }
  }
});

Use any color format (hex, rgb, hsl, oklch, etc.). The plugin automatically generates "on-" colors for optimal text contrast.

CSS Variable References: You can also reference other CSS variables in your configuration:

module.exports = frontile({
  themes: {
    light: {
      colors: {
        primary: {
          subtle: 'var(--color-surface-solid-6)',
        }
      }
    }
  }
});

Note: When using CSS variable references, automatic "on-" color generation is skipped since the actual color value isn't known at build time. You'll need to manually define the corresponding "on-" colors if needed.

Customizing On-Colors

The theme system automatically generates "on-color" variants (e.g., on-primary, on-success) for semantic colors to ensure optimal text contrast. These colors are used as text/foreground colors on semantic backgrounds.

By default, on-colors are calculated using WCAG contrast guidelines and will be either pure white or pure black. However, you can override these auto-generated colors to match your brand or design requirements:

const { frontile } = require('@frontile/theme/plugin');

module.exports = frontile({
  themes: {
    light: {
      colors: {
        // Define background colors as usual
        primary: {
          subtle: '#3b82f6',
          soft: '#2563eb',
          strong: '#1e3a8a',
          DEFAULT: '#1e40af'
        },
        // Override on-colors to use custom values
        'on-primary': {
          subtle: '#ffffff',      // Pure white
          soft: '#e0f2ff',        // Light blue tint instead of pure white
          strong: '#bfdbfe',      // Lighter blue
          DEFAULT: '#ffffff'      // Pure white
        }
      }
    }
  }
});

Partial overrides are supported - any variants you don't define will still be auto-generated:

module.exports = frontile({
  themes: {
    light: {
      colors: {
        primary: {
          subtle: '#3b82f6',
          DEFAULT: '#1e40af',
          strong: '#1e3a8a',
        },
        'on-primary': {
          DEFAULT: '#e0f2ff',  // Only override the DEFAULT level, others auto-generate
        }
      }
    }
  }
});

You can override on-colors for any semantic color category:

  • on-neutral, on-primary, on-secondary, on-tertiary, on-success, on-warning, on-danger
  • on-surface-modal

Option 2: Via CSS Variables

Override colors directly in your CSS:

@import "tailwindcss" source("../../");
@plugin "@frontile/theme/plugin/default";
@source '../../node_modules/@frontile';

@theme {
  /* Override primary colors */
  --color-primary-subtle: #3b82f6;
  --color-primary: #2563eb;
  --color-primary-strong: #1d4ed8;

  /* Manually define "on-" colors for text contrast */
  --color-on-primary-subtle: #ffffff;
  --color-on-primary: #ffffff;
  --color-on-primary-strong: #ffffff;
}

Note: When defining colors via CSS, you must manually define corresponding "on-" colors. The plugin cannot automatically generate them because CSS variable values are not accessible at build time.

Documentation

Visit frontile.dev to read the docs and see live demos.

License

This project is licensed under the MIT License.

版本与发布记录

@frontile/theme 共发布 78 个版本,首次发布于 2024/01/10;过去 12 个月发布了 35 个版本。

版本发布日期距今
0.18.9latest2026/11/142 天前
0.18.82026/11/123 天前
0.18.72026/11/115 天前
0.18.62026/11/0411 天前
0.18.52026/11/0312 天前
0.18.32026/10/2026 天前

关于 @frontile/theme 的常见问题

@frontile/theme 是什么?

Component Library for Ember Octane apps: Theme

如何安装 @frontile/theme?

在项目目录运行 npm install @frontile/theme,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:tailwindcss(*)、ember-source(>= 4.12.0)、@babel/runtime(>= 7)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@frontile/theme 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@frontile/theme 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@frontile/theme 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js 10.* || >= 12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@frontile/theme 可以商用吗?

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

@frontile/theme 的下载量有多少?

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

@frontile/theme 还在维护吗?

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