The stack layout in modern CSS

This week, we learn how Kelp UI implements the container layout pattern, the cluster layout, and the split layout.
Today, we’re going to look at one last layout pattern in Kelp: the stack. Let’s dig in!
The stack layout In Kelp, most elements have spacing applied them by default.
This lets you write content without having to worry about margins or padding between elements. You don’t need to wrap everything in classes.


This content originally appeared on Go Make Things and was authored by Go Make Things

This week, we learn how Kelp UI implements the container layout pattern, the cluster layout, and the split layout.

Today, we’re going to look at one last layout pattern in Kelp: the stack. Let’s dig in!

The stack layout

In Kelp, most elements have spacing applied them by default.

This lets you write content without having to worry about margins or padding between elements. You don’t need to wrap everything in classes.

But sometimes, you want to more tightly control the spacing between things. A common example of this might be a form, where you want a controlled amount of space between each field.

This stack layout is perfect for that.

<form class="stack">
	<div>
		<label for="username">Username</label>
		<input type="text" id="username">
	</div>
	<div>
		<label for="password">Password</label>
		<input type="password" id="password">
	</div>
	<button>Login</button>
</form>

As always, we’ll remove any margin from the direct child elements so that we can control that directly.

.stack > * {
	margin: 0;
}

Then, we’ll use flexbox with a flex-direction of column to create a vertical layout (in top-to-bottom languages).

The --gap variable, as always, let’s us control and easily modify the amount of spacing between our items.

.stack {
	--gap: 1em;
	display: flex;
	flex-direction: column;
	gap: var(--gap);
}

Here’s a demo of the .stack layout.

Adjusting spacing

With all of these layouts, we’ve used the gap property to control the space between items. Tomorrow, I’ll share the small assortment of utility classes Kelp uses to adjust that spacing.

You can learn more about Kelp over at KelpUI.com.

Need a developer but don't need a full-time employee? I now offer subscription full stack engineering. Ship faster and build better systems. Pause or cancel any time.

Cheers,
Chris


This content originally appeared on Go Make Things and was authored by Go Make Things


Print Share Comment Cite Upload Translate Updates
APA

Go Make Things | Sciencx (2025-06-12T14:30:00+00:00) The stack layout in modern CSS. Retrieved from https://www.scien.cx/2025/06/12/the-stack-layout-in-modern-css/

MLA
" » The stack layout in modern CSS." Go Make Things | Sciencx - Thursday June 12, 2025, https://www.scien.cx/2025/06/12/the-stack-layout-in-modern-css/
HARVARD
Go Make Things | Sciencx Thursday June 12, 2025 » The stack layout in modern CSS., viewed ,<https://www.scien.cx/2025/06/12/the-stack-layout-in-modern-css/>
VANCOUVER
Go Make Things | Sciencx - » The stack layout in modern CSS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/06/12/the-stack-layout-in-modern-css/
CHICAGO
" » The stack layout in modern CSS." Go Make Things | Sciencx - Accessed . https://www.scien.cx/2025/06/12/the-stack-layout-in-modern-css/
IEEE
" » The stack layout in modern CSS." Go Make Things | Sciencx [Online]. Available: https://www.scien.cx/2025/06/12/the-stack-layout-in-modern-css/. [Accessed: ]
rf:citation
» The stack layout in modern CSS | Go Make Things | Sciencx | https://www.scien.cx/2025/06/12/the-stack-layout-in-modern-css/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.