Guides

Retool Container Padding Removal: Fix Nested Layout Issues

OTC Team··5 min read

If you've spent any time building real-world apps in Retool, you've almost certainly run into the Retool container padding removal problem. You nest one container inside another to logically group components, and suddenly your UI looks like a series of bloated, over-padded boxes stacked inside each other. There's no built-in switch to remove the padding. You're left fighting the layout system instead of building your app. This guide explains exactly why it happens, what the community has figured out, and how to fix it today with a working CSS snippet.

Why Retool Container Padding Causes Layout Problems

In standard web development, a <div> is a neutral wrapper — zero default padding, no visual footprint unless you add one. In Retool, the container component doesn't work that way. Every container ships with built-in padding that you cannot remove through the component's native settings panel. When you nest containers — which is completely normal when building anything beyond a simple single-page form — that padding multiplies. The result is a UI that feels cramped, misaligned, and amateurish, even when your underlying logic is solid.

Developers in the Retool community forum have flagged this as one of the most universally painful issues on the platform. The use case is always the same: you want a container to behave like a plain grouping element — controlling visibility of a set of components together without adding any visual overhead. Right now, you can't do that cleanly.

Why You Can't Just Set Visibility Per Component

The obvious workaround is to skip containers and toggle the hidden property on each individual component instead. But this breaks the DRY principle fast. If you have eight components that should show or hide together, you're now managing eight separate visibility conditions. When your logic changes, you have to update all eight. It's harder to read, harder to maintain, and much easier to introduce bugs. A container that groups components and exposes a single hidden toggle is the right abstraction — it just needs zero padding to be useful.

The CSS Workaround That Actually Works

The Retool support team shared a custom CSS snippet in the community thread that removes padding from all direct child components inside a specific container. Here's how to apply it:

  • Open your Retool app and navigate to the App Settings panel (the gear icon in the top right).
  • Select Custom CSS from the left sidebar.
  • Replace container1 in the snippet below with the actual name of your container component (check the component's name in the left panel).
  • Paste the following CSS and save:

/* Works on Retool 2.124.0 */
/* Remove padding from direct children of container1 */
#retool-widget-container1 > div > div > div > div > div > div > span > div > section > div > div > div { padding: 0px !important; }
#retool-widget-container1 > div > div > div > div > div > div > span > div > section > div > div > div > div > div > div > div > div._hPGyJ { padding: 0px !important; }

Important caveats: This CSS targets Retool's internal DOM structure, which is version-specific. It was confirmed working on 2.124.0 but may break after a Retool version upgrade. Treat it as a temporary fix, not a permanent solution. Also note that you'll need a separate rule block for every container you want to strip padding from — just duplicate the snippet and swap the widget ID each time.

What About Forms and Tabbed Containers?

The padding problem isn't limited to standard containers. form components and tabbed container components suffer from the same issue. The same CSS approach can work, but the internal DOM path may differ slightly between component types. You'll need to use your browser's DevTools inspector to find the correct selector chain if the snippet above doesn't produce results on a form or tab container. Right-click the padded area in preview mode, select Inspect, and trace the selector path from the #retool-widget-[name] root element down to the padding node.

Is Retool Planning to Fix This Natively?

Yes — and it's been officially acknowledged. A Retool team member responded in the community thread confirming that customizable padding for containers was actively being worked on, with a release expected within a month of that post. The longer-term direction is toward a full padding control UI similar to what tools like FlutterFlow offer: independent top, right, bottom, and left padding fields with a lock toggle to apply values uniformly.

Until that ships, the CSS workaround above is your best option. Keep an eye on Retool's changelog and the community forum for the release announcement.

How to Structure Nested Containers in the Meantime

If you're building a complex layout right now and can't wait, here are a few practical tips to reduce the visual impact of container padding:

  • Use the background color setting on inner containers to match the parent container's background — this makes the padding boundary invisible even if it's still there spatially.
  • Apply the custom CSS snippet above to every container in your nesting chain, not just the outermost one.
  • Where possible, flatten your component hierarchy. If two containers serve only as visibility wrappers and contain no visual boundary, consider whether a single container with conditional component rendering can replace both.
  • Name your containers clearly (e.g., container_userProfileGroup) so your CSS overrides are easy to identify and update after version upgrades.

The Bottom Line

Retool container padding is one of those issues that feels minor until you're building anything with real UI complexity — then it becomes a constant friction point. The CSS workaround works today, it's version-sensitive, and a native fix is on Retool's roadmap. Apply the snippet, document which version it was tested on, and plan to revisit it after any major Retool upgrade. When the native padding controls ship, migrating away from the CSS override will be straightforward.

Ready to build?

We scope, design, and ship your Retool app — fast.

Ready to ship your first tool?