chakra-ui---component-composition

chakra-ui---component-composition is a cursor rule for coding agents from holtwood/awesome-cursorrules-zh. It costs 0 tokens per session (524 once invoked), scanned A, original, MIT.

A React component-structure rule for composing Chakra UI components into reusable interfaces. It favors small custom components built from layout and interface pieces such as Box, Flex, and Stack.

In plain words
What is it for?
Use it to extend Chakra components with props, render them as other HTML elements, and pass refs through custom components.
Why use it?
It keeps styling and UI behavior consistent while making complex components easier to reuse and maintain.

Cursor rule

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.

agentmods
npx agentmods add rules/holtwood/awesome-cursorrules-zh/chakra-ui-component-composition
Clone the repo
git clone --depth 1 https://github.com/holtwood/awesome-cursorrules-zh

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---component-composition

README.md
[![agentmods](https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/chakra-ui-component-composition.svg)](https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/chakra-ui-component-composition)
Your own site
<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/chakra-ui-component-composition"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/chakra-ui-component-composition.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 524 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.00524
Opus 5 $0.00000 $0.00262
Sonnet 5 $0.00000 $0.00105
Haiku 4.5 $0.00000 $0.00052

Measured yesterday against content hash dfba7b9dfbbf, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

chakra-ui---component-composition 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 yesterday.

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---component-composition.mdc · 50 lines

What it actually says

  • 使用 Chakra UI 实现适当的组件组合
    • 利用 as prop:Chakra UI 组件支持 as prop,允许将组件渲染为不同的 HTML 元素或 React 组件,这在构建灵活的 UI 时非常有用。
    • 扩展现有组件:通过直接传递 Chakra UI 组件的 props 来扩展其样式和行为,而不是重新创建组件。
    • 自定义组件的封装:将复杂的 UI 逻辑和样式封装在自定义组件中,并使用 BoxFlexStack 等布局组件进行组合,保持组件的单一职责和可复用性。
    • 使用 forwardRef:当自定义组件需要转发 ref 时,使用 forwardRef 确保其与 Chakra UI 组件的兼容性。
    • 示例
      import { Box, Flex, Text, Button } from '@chakra-ui/react';
      
      function Card({ title, description, buttonText, ...rest }) {
        return (
          <Box p={5} shadow="md" borderWidth="1px" {...rest}>
            <Flex alignItems="baseline">
              <Text fontSize="xl" fontWeight="semibold" lineHeight="short">
                {title}
              </Text>
            </Flex>
            <Text mt={2}>{description}</Text>
            <Button mt={4} colorScheme="teal">
              {buttonText}
            </Button>
          </Box>
        );
      }
      
      // 使用示例
      function MyPage() {
        return (
          <Flex direction="column" gap={4}>
            <Card
              title="Card Title 1"
              description="This is a description for card 1."
              buttonText="Action 1"
            />
            <Card
              title="Card Title 2"
              description="This is a description for card 2."
              buttonText="Action 2"
              bg="blue.50"
            />
          </Flex>
        );
      }
      
    • 避免过度封装:在某些情况下,直接使用 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. yesterday First seen · 50 lines · 0 tokens per session scan A dfba7b9dfbbf

Subscribe to this mod's changes

chakra-ui---component-composition is a cursor rule published in the GitHub repository holtwood/awesome-cursorrules-zh (232 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 524 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.