Card With Children Slot
ReactJS
Easy
5 views
Problem Description
Make a Card component that accepts children and keeps the same look everywhere.
Output Format
Render a React component.
Constraints
Use children prop for composition.
Official Solution
import React from 'react';
export function Card({ title, children }) {
return (
<section style={{ border: '1px solid #eee', borderRadius: 14, padding: 14, width: 360 }}>
<h2 style={{ margin: '0 0 8px 0' }}>{title}</h2>
<div>{children}</div>
</section>
);
}
export default function App() {
return (
<Card title='meetcode'>
<p style={{ margin: 0 }}>Small questions. Daily practice.</p>
<a href='#' style={{ display: 'inline-block', marginTop: 10, color: '#0a58ca' }}>Open topics</a>
</Card>
);
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!