Between component tag

Between component tag

In React, anything that is between the tag is passed as children prop.

Example

// between-component-tag-Highlight.jsx
export const Highlight = ({ children, color }) => (
    <span
        style={{
            backgroundColor: color,
            color: 'black',
        }}>
        {children}
    </span>
)
{/* Main.mdx */}
import { Highlight } from './between-component-tag-Highlight.jsx';

<Highlight color="lime">Lime</Highlight>
<Highlight color="cyan">Cyan</Highlight>

Output

LimeCyan