RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Cursor rules/NoDeskAI/browser-pilot

Cursor rule

.cursor/rules/tailwind-css-color-mix.mdc

Tailwind CSS 结合十六进制 CSS 变量与透明度时的避坑指南及 color-mix 原生替代方案

Cursor rules

Quality

50/100

Scores the file, not the repository.

Length

141 words

6 headings · 3 code blocks

Repository

34

— · pushed 25 days ago

Last changed

3 days ago

First indexed 3 days ago.
NoDeskAI/browser-pilot/.cursor/rules/tailwind-css-color-mix.mdcRawGitHub
1---
2description: Tailwind CSS 结合十六进制 CSS 变量与透明度时的避坑指南及 color-mix 原生替代方案
3globs: frontend/**/*.{css,vue,ts,tsx}
4alwaysApply: false
5---
6 
7# Tailwind CSS 变量透明度与原生 CSS 避坑指南
8 
9当项目中的 CSS 变量(如 `--muted-foreground`)定义为**绝对十六进制值**(如 `#a0a0a0`)时,在与 Tailwind 的透明度修饰符(如 `/30`)结合使用,或在全局原生伪元素(如 `::-webkit-scrollbar`)中混用时,极易产生编译失败或浏览器无法识别的无效 CSS。
10 
11## 核心避坑规则
12 
13### 1. 谨慎在伪元素/原生 CSS 中使用 `@apply` 加透明度
14 
15当全局变量为 `#hex` 格式时,Tailwind 会将 `@apply bg-muted-foreground/30` 尝试编译为 `rgba(#a0a0a0, 0.3)`,这是**非法的 CSS 语法**,会导致浏览器静默丢弃该规则(例如导致自定义滚动条样式失效,回退为原生丑陋的样式)。
16 
17```css
18/* ❌ BAD: 当变量是十六进制时,会编译出非法 CSS rgba(#a0a0a0, 0.3) */
19::-webkit-scrollbar-thumb {
20 @apply bg-muted-foreground/30 rounded-full;
21}
22```
23 
24### 2. 使用 `color-mix()` 作为安全、现代的透明度替代方案
25 
26在必须写原生 CSS(如自定义滚动条)或者脱离 Tailwind 工具类的地方,**请直接使用现代原生的 `color-mix` 函数**来进行颜色和透明度的混合。它能完美解析十六进制变量并实现等效的透明度效果!
27 
28```css
29/* ✅ GOOD: 使用纯原生现代 CSS 函数进行透明度混合,100% 兼容十六进制变量 */
30::-webkit-scrollbar-thumb {
31 background-color: color-mix(in srgb, var(--muted-foreground) 30%, transparent);
32 border-radius: 9999px;
33}
34```
35 
36### 3. 注意原生属性对颜色的支持格式
37 
38在如 `scrollbar-color` 等原生属性中,同样不可使用 `hsl(var(--xxx) / 0.3)` 去包裹一个十六进制变量。
39 
40```css
41/* ❌ BAD: 将十六进制传入 hsl 函数也是非法的 */
42* {
43 scrollbar-color: hsl(var(--muted-foreground) / 0.3) transparent;
44}
45 
46/* ✅ GOOD: 统一使用 color-mix 解决透明度混合 */
47* {
48 scrollbar-color: color-mix(in srgb, var(--muted-foreground) 30%, transparent) transparent;
49}
50```
51 
52## 适用场景
53当你修改全局 `style.css`、自定义浏览器原生控件样式(如滚动条、range input 等)或在 `.vue` 组件的 `<style>` 块中编写原生 CSS 且需要结合透明度时,请务必遵守此规则,首选 `color-mix()`。

Sections

  • Tailwind CSS 变量透明度与原生 CSS 避坑指南
  • 核心避坑规则
  • 1. 谨慎在伪元素/原生 CSS 中使用 `@apply` 加透明度
  • 2. 使用 `color-mix()` 作为安全、现代的透明度替代方案
  • 3. 注意原生属性对颜色的支持格式
  • 适用场景

What it covers

ui

Stack — with the evidence

docker

(1.00)

python

(0.80)

node

(0.70)

vue

(0.70)

fastapi

(0.70)

postgres

(0.70)

tailwind

(0.70)

vite

(0.70)

aws

(0.70)

typescript

(0.60)

javascript

(0.50)

Glob targeting

  • frontend/**/*.{css
  • vue
  • ts
  • tsx}

Format

Cursor rules

The most expressive format here. Many small .mdc files, each with frontmatter declaring when it should load, so a rule about migrations only enters context when a migration is open. Costs the most to maintain and only one editor reads it.

What the corpus says about it

Repository

Owner
NoDeskAI
Language
—
License
—
Archived
no

All configs in this repo

Also in NoDeskAI/browser-pilot

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
NoDeskAI/browser-pilot.cursor/rules/build-from-user-perspective.mdc · 34Cursor rulesdockernode+9buildsecurity51/1003 days ago
NoDeskAI/browser-pilot.cursor/rules/debug-container.mdc · 34Cursor rulesdockerpython+9api65/1003 days ago
NoDeskAI/browser-pilot.cursor/rules/deploy.mdc · 34Cursor rulesdockerpython+9no sections38/1003 days ago
NoDeskAI/browser-pilot.cursor/rules/env-vars.mdc · 34Cursor rulesdockerpython+9setup63/1003 days ago
NoDeskAI/browser-pilot.cursor/rules/fingerprint-popover-sync.mdc · 34Cursor rulesdockerpython+9no sections25/1003 days ago
NoDeskAI/browser-pilot.cursor/rules/keyboard-shortcuts-ux.mdc · 34Cursor rulesdockerpython+9ui31/1003 days ago
NoDeskAI/browser-pilot.cursor/rules/plan-ui-summary.mdc · 34Cursor rulesdockerpython+9ui54/1003 days ago
NoDeskAI/browser-pilot.cursor/rules/ux-ui-daynight.mdc · 34Cursor rulesdockerpython+9lint-formatui54/1003 days ago
NoDeskAI/browser-pilot.cursor/rules/verify-before-claim.mdc · 34Cursor rulesdockerpython+9no sections50/1003 days ago
Diff against .cursor/rules/build-from-user-perspective.mdc Diff against .cursor/rules/debug-container.mdc Diff against .cursor/rules/deploy.mdc Diff against .cursor/rules/env-vars.mdc Diff against .cursor/rules/fingerprint-popover-sync.mdc Diff against .cursor/rules/keyboard-shortcuts-ux.mdc Diff against .cursor/rules/plan-ui-summary.mdc Diff against .cursor/rules/ux-ui-daynight.mdc Diff against .cursor/rules/verify-before-claim.mdc

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45Cursor rulestypescriptpytest+15testlint-formatstylearch+5100/1003 days ago
hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126Cursor rulesgobun+5setupbuildtestlint-format+6100/1003 days ago
Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+13setuptestlint-formatstyle+799/1003 days ago
deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1Cursor rulestypescriptnextjs+5setuptestlint-formatstyle+799/1003 days ago
markstev/mark-starter.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+14setuptestlint-formatstyle+699/1003 days ago
dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+15setuptestlint-formatstyle+799/1003 days ago
langflow-ai/langflow.cursor/rules/docs_development.mdc · 153kCursor rulespythonnode+16setupbuildtestlint-format+797/1003 days ago
TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45Cursor rulestypescriptpytest+15teststyletesting-strategysecurity+397/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack