<figure style="display: none;">
<img src="https://fillmurray.com/400/600" alt="A beautiful Bill Murray placeholder image" />
<figcaption>
A beautiful Bill Murray placeholder image
</figcaption>
</figure>
style="display: none;"
While HTML is used to define the structure and semantics of your content, CSS is used to style it and lay it out.
Layout components lead to anger...
The inevitable end of layout components is this API...
<div style="/* Whatever* CSS you want */">
Elise Hein
<Columns style={ { height: "100vh" } }>
<Column as="nav">Navigation</Column>
<Column as="main">Main content</Column>
</Columns>
Sebastian Weber
article > * + * {
margin: 1em 0;
}
It also reinforces patterns that separate concerns because the actual UI components are layout-agnostic and don’t have to care where they are used. This is the job of the container element
Components style themselves, and position their immediate children.
-Me
const Button = () => (
<button>
The only content you could possibly need.
</button>
);
const Button = ({ children }) => (
<button>
{children}
</button>
);
const Button = style(({ children, className }) => (
<button className={className}>
{children}
</button>
))`
border: none;
border-radius: 4px;
background-color: rebeccapurple;
color: lavender;
padding: 1em;
margin: 2rem;
`;
const Menu = styled(({ className }) => (
<menu className={className}>
<Button>Pick Me!</Button>
<Button>No, Pick Me!</Button>
</menu>
))`
background: #eee;
`
const Button = style(({ children, className }) => (
))`
margin: 2rem;
`;
const Button = style(({ children, className }) => (
<button className={className}>
{children}
</button>
))`
border: none;
border-radius: 4px;
background-color: rebeccapurple;
color: lavender;
padding: 1em;
`;
const Menu = styled(({ className }) => (
<menu className={className}>
<Button>Pick Me!</Button>
<Button>No, Pick Me!</Button>
</menu>
))`
background: #eee;
display: flex;
& > ${Button}:last-child {
margin-left: auto;
}
`;
const Menu = styled(({ className }) => (
))`
& > ${Button}:last-child {
margin-left: auto;
}
`;
From "CSS Box Model" by Nicha Jutasirivongse
Components style themselves, and
position their immediate children.-Me
Anything that affects only the border-box inward, is style.
Everything else is position.-Also Me
Layout components solve the wrong problem.
-Still Me
Components style themselves, and
position their immediate children.-Me
Components style themselves, and
apply context to their immediate children.-Me