Files
mintlify__docs/react-components.mdx
Ethan Palm 3a37747f1b Content refresh (#910)
* Update Quickstart page for style and clarity

- Improve readability and flow
- Make language more concise and consistent
- Remove unnecessary periods from numbered lists
- Clarify instructions and terminology

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Expandables component page

- Add clear introduction explaining the component's purpose
- Remove unnecessary period from description
- Improve formatting consistency for boolean values
- Enhance clarity in prop descriptions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Fields component page

- Add clear introduction explaining field components
- Improve consistency in component naming conventions
- Remove unnecessary periods from descriptions
- Improve punctuation and clarity
- Add comma for better readability in example

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Icons component page

- Add clear introduction explaining the Icon component
- Improve language clarity and flow
- Remove unnecessary periods from prop descriptions
- Replace 'e.g.' with 'for example' for consistency
- Remove trailing space from inline example

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Mermaid diagrams page

- Add clear introduction explaining Mermaid's purpose and capabilities
- Improve clarity and conciseness of descriptions
- Simplify section heading from 'Syntax for Mermaid diagrams' to 'Syntax'
- Make language more precise and user-focused
- Update code comment to be more generic

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Steps component page

- Add clear introduction explaining the Steps component
- Improve language clarity and consistency
- Remove unnecessary periods from prop descriptions
- Add Oxford comma for better readability
- Make description more action-oriented

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Tabs component page

- Add clear introduction explaining the Tabs component purpose
- Improve clarity and user understanding
- Remove unnecessary period from prop description
- Make description more informative about component functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Migrations guide page

- Improve language clarity and conciseness
- Remove unnecessary periods from command descriptions
- Enhance section structure with proper headings
- Update terminology for consistency
- Add OpenAPI migration section header for better organization

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update React components page

- Improve language clarity and conciseness throughout
- Simplify and tighten explanatory text
- Fix capitalization in performance best practices
- Remove redundant phrases for better flow
- Enhance readability and user experience

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Redirects and broken links page

- Improve language clarity and conciseness
- Remove unnecessary words like 'Simply' and 'will'
- Use present tense for more direct communication
- Fix preposition usage for better grammar
- Streamline explanations for better readability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update Support integrations page

- Improve language clarity and directness
- Remove unnecessary words for better flow
- Use more direct phrasing for instructions
- Simplify conditional language for better readability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update CI checks page

- Improve language clarity and conciseness throughout
- Remove unnecessary words and phrases
- Use present tense for more direct communication
- Fix grammar issues and improve flow
- Replace 'in-built' with 'built-in' for standard terminology
- Streamline explanations for better readability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* quickstart edits

* Update cards

* Apply style lessons learned from quickstart and cards feedback

- Use action-oriented introductions ("Use X to..." instead of "The X component...")
- Apply sentence case to all section headings ("Properties" not "Props")
- Use "Properties" consistently instead of "Props"
- Remove unnecessary periods from property descriptions
- Update component headings to sentence case
- Make language more direct and user-focused

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix typo

* review exapandables

* update fields

* update icons

* update mermaid

* update steps

* update tabs

* update migration

* Update react-components.mdx

* Update broken-links.mdx

* Update overview.mdx

* Update ci.mdx

* Document style preferences learned from content refresh project

Add detailed style guide based on patterns identified during DOC-84
content refresh work, including:
- Heading and formatting conventions
- Component introduction patterns
- Property description standards
- Language and tone preferences
- Code example best practices
- Content organization principles

These learnings will help maintain consistency in future documentation updates.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* add reviewer feedback

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-15 16:59:47 -07:00

211 lines
6.7 KiB
Plaintext

---
title: "React"
description: "Build interactive and reusable elements with React components"
icon: "react"
---
import { Counter } from "/snippets/counter.mdx";
import { ColorGenerator } from "/snippets/color-generator.jsx";
[React components](https://react.dev) are a powerful way to create interactive and reusable elements in your documentation.
You can use React components directly in your `MDX` files without any additional setup.
## Using React components
You can build components directly in your MDX files using [React hooks](https://react.dev/reference/react/hooks).
### Basic example
Here is a basic example of a counter component:
```mdx
export const Counter = () => {
const [count, setCount] = useState(0);
return (
<div>
<p>Current count: {count}</p>
<button onClick={() => setCount(count + 1)}>
+
</button>
</div>
);
}
```
The `Counter` component can be used in your `MDX` files like this:
```mdx
<Counter />
```
The counter renders as an interactive React component.
<Counter />
## Importing components
Just like in regular React, you can import components from other files.
```mdx
import { ColorGenerator } from "/snippets/color-generator.jsx"
```
<Warning>
Unlike regular React, you can't import components from every `MDX` file. Reusable components can only be referenced from `MDX` files within the `snippets` folder.
</Warning>
After importing the component, use it in your `MDX` files like this:
```mdx
<ColorGenerator />
```
Learn more about [reusable snippets](/reusable-snippets).
### Complex example
You can build much more complex components. Here is an example of a color generator component that uses multiple React hooks:
```mdx /snippets/color-generator.jsx [expandable]
export const ColorGenerator = () => {
const [hue, setHue] = useState(180)
const [saturation, setSaturation] = useState(50)
const [lightness, setLightness] = useState(50)
const [colors, setColors] = useState([])
useEffect(() => {
const newColors = []
for (let i = 0; i < 5; i++) {
const l = Math.max(10, Math.min(90, lightness - 20 + i * 10))
newColors.push(`hsl(${hue}, ${saturation}%, ${l}%)`)
}
setColors(newColors)
}, [hue, saturation, lightness])
const copyToClipboard = (color) => {
navigator.clipboard
.writeText(color)
.then(() => {
console.log(`Copied ${color} to clipboard!`)
})
.catch((err) => {
console.error("Failed to copy: ", err)
})
}
return (
<div className="p-4 border dark:border-zinc-950/80 rounded-xl not-prose">
<div className="space-y-4">
<div className="space-y-2">
<label className="block text-sm text-zinc-950/70 dark:text-white/70">
Hue: {hue}°
<input
type="range"
min="0"
max="360"
value={hue}
onChange={(e) => setHue(Number.parseInt(e.target.value))}
className="w-full h-2 bg-zinc-950/20 rounded-lg appearance-none cursor-pointer dark:bg-white/20 mt-1"
style={{
background: `linear-gradient(to right,
hsl(0, ${saturation}%, ${lightness}%),
hsl(60, ${saturation}%, ${lightness}%),
hsl(120, ${saturation}%, ${lightness}%),
hsl(180, ${saturation}%, ${lightness}%),
hsl(240, ${saturation}%, ${lightness}%),
hsl(300, ${saturation}%, ${lightness}%),
hsl(360, ${saturation}%, ${lightness}%))`,
}}
/>
</label>
<label className="block text-sm text-zinc-950/70 dark:text-white/70">
Saturation: {saturation}%
<input
type="range"
min="0"
max="100"
value={saturation}
onChange={(e) => setSaturation(Number.parseInt(e.target.value))}
className="w-full h-2 bg-zinc-950/20 rounded-lg appearance-none cursor-pointer dark:bg-white/20 mt-1"
style={{
background: `linear-gradient(to right,
hsl(${hue}, 0%, ${lightness}%),
hsl(${hue}, 50%, ${lightness}%),
hsl(${hue}, 100%, ${lightness}%))`,
}}
/>
</label>
<label className="block text-sm text-zinc-950/70 dark:text-white/70">
Lightness: {lightness}%
<input
type="range"
min="0"
max="100"
value={lightness}
onChange={(e) => setLightness(Number.parseInt(e.target.value))}
className="w-full h-2 bg-zinc-950/20 rounded-lg appearance-none cursor-pointer dark:bg-white/20 mt-1"
style={{
background: `linear-gradient(to right,
hsl(${hue}, ${saturation}%, 0%),
hsl(${hue}, ${saturation}%, 50%),
hsl(${hue}, ${saturation}%, 100%))`,
}}
/>
</label>
</div>
<div className="flex space-x-1">
{colors.map((color, idx) => (
<div
key={idx}
className="h-16 rounded flex-1 cursor-pointer transition-transform hover:scale-105"
style={{ backgroundColor: color }}
title={`Click to copy: ${color}`}
onClick={() => copyToClipboard(color)}
/>
))}
</div>
<div className="text-sm font-mono text-zinc-950/70 dark:text-white/70">
<p>
Base color: hsl({hue}, {saturation}%, {lightness}%)
</p>
</div>
</div>
</div>
)
}
```
The `ColorGenerator` component can be used in your `MDX` files like this:
```mdx
<ColorGenerator />
```
The color generator renders as an interactive React component.
<ColorGenerator />
## Considerations
<AccordionGroup>
<Accordion title="Client-side rendering impact">
React hook components render on the client-side, which has several implications:
- **SEO**: Search engines might not fully index dynamic content.
- **Initial load**: Visitors may experience a flash of loading content before components render.
- **Accessibility**: Ensure dynamic content changes are announced to screen readers.
</Accordion>
<Accordion title="Performance best practices">
- **Optimize dependency arrays**: Include only necessary dependencies in your `useEffect` dependency arrays.
- **Memoize complex calculations**: Use `useMemo` or `useCallback` for expensive operations.
- **Reduce re-renders**: Break large components into smaller ones to prevent cascading re-renders.
- **Lazy loading**: Consider lazy loading complex components to improve initial page load time.
</Accordion>
</AccordionGroup>