chakra-ui-best-practices

chakra-ui-best-practices is a cursor rule for Cursor from holtwood/awesome-cursorrules-zh. It costs 0 tokens per session (624 once invoked), scanned A, original, MIT.

A set of rules for building React interfaces with Chakra UI, a component library for styled and accessible user interfaces. It covers themes, responsive layouts, accessibility, performance, and reusable components.

In plain words
What is it for?
Use it when creating or reviewing Chakra UI components, themes, responsive layouts, dialogs, notifications, color modes, and long lists in a React app.
Why use it?
It helps keep the interface consistent and avoids scattered custom CSS and repeated implementation choices. It also gives developers shared guidance for accessibility and common Chakra UI features.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when creating or reviewing Chakra UI components, themes, responsive layouts, dialogs, notifications, color modes, and long lists in a React app.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/holtwood/awesome-cursorrules-zh/chakra-ui-best-practices
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/holtwood/awesome-cursorrules-zh

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for chakra-ui-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/chakra-ui-best-practices/github.svg)](https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/chakra-ui-best-practices)
Your own site
<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/chakra-ui-best-practices"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/chakra-ui-best-practices/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for chakra-ui-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/chakra-ui-best-practices"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/chakra-ui-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 624 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00624
Opus 5 $0.00000 $0.00312
Sonnet 5 $0.00000 $0.00125
Haiku 4.5 $0.00000 $0.00062

Measured 6d ago against content hash 804dfb8e9dac, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

chakra-ui-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/rules/frontend/react/chakra-ui/chakra-ui-best-practices.mdc · 43 lines

What it actually says

  • 在应用程序根部使用 ChakraProvider
    • 确保在 React 应用程序的根组件中包裹 ChakraProvider,以便所有 Chakra UI 组件都能访问主题和上下文。
    • 示例:
      import { ChakraProvider } from '@chakra-ui/react';
      import customTheme from './theme'; // 假设你的主题文件在 './theme/index.js'
      
      function App() {
        return (
          <ChakraProvider theme={customTheme}>
            {/* 你的应用程序内容 */}
          </ChakraProvider>
        );
      }
      
  • 利用 Chakra UI 组件实现一致的设计
    • 优先使用 Chakra UI 提供的组件来构建 UI,而不是编写自定义 CSS,以确保设计的一致性和可维护性。
    • 充分利用其内置的样式 props 和组合能力。
  • 实现自定义主题以进行品牌特定的样式设计
    • 通过 extendTheme 函数定制颜色、字体、间距、组件样式等,以匹配品牌指南。
    • 将主题配置分解为模块化文件(如 foundationscomponents 目录),提高可组织性。
  • 使用 Chakra UI 断点系统的响应式样式
    • 利用 Chakra UI 的响应式样式语法(数组或对象语法)来轻松实现跨设备的响应式布局和样式。
    • 示例:fontSize={{ base: 'md', md: 'lg', lg: 'xl' }}
  • 利用 Chakra UI hooks 增强功能
    • 使用 useDisclosure 管理模态框、抽屉等的打开/关闭状态。
    • 使用 useToast 显示通知。
    • 使用 useBreakpointValue 根据断点获取值。
    • 使用 useColorMode 管理亮/暗模式。
  • 可访问性
    • 始终关注可访问性,利用 Chakra UI 内置的 WAI-ARIA 支持和语义化 HTML 渲染。
    • 确保键盘导航、焦点管理和颜色对比度符合标准。
  • 性能优化
    • 按需导入组件,避免不必要的重新渲染(使用 React.memouseCallbackuseMemo)。
    • 对于长列表,考虑使用虚拟化。
  • 组件组合
    • 善用 as prop 来改变组件渲染的底层 HTML 元素,实现语义化。
    • 将复杂逻辑封装在自定义组件中,并使用 Chakra UI 的布局组件进行组合。
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 43 lines · 0 tokens per session scan A 804dfb8e9dac

Subscribe to this mod's changes

chakra-ui-best-practices is a cursor rule published in the GitHub repository holtwood/awesome-cursorrules-zh (233 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 624 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.