Skip to main content
ExodeUI

EXODEUI DESKTOP

A little space for good ideas.

Choose your platform to get the official ExodeUI installer.

Looking for Intel Mac or other builds? Explore the web studio or check all download options.

Prefer the browser? Try for free in your browser →
Concepts1 min read·Updated November 2026·By the ExodeUI team

Nine-Slice Scaling: How to Resize UI Graphics Without Distortion

What nine-slice scaling is, how CSS border-image, Android 9-patch and game engines use it, and when to use it for buttons, panels and animated UI.

Direct Summary & Definition

Core Takeaway

Nine-slice scaling splits an image into a three-by-three grid. The four corners stay the same size, the four edges stretch in one direction, and the centre stretches in both. It lets a decorated button, panel or speech bubble grow to fit its content without distorting the corners. CSS border-image, Android 9-patch images and most game engines support it.

How the nine slices work

Picture a rounded, decorated panel. If you scale the whole image, the corners blur and the borders get thick. Nine-slice scaling avoids that by defining four guide lines that cut the image into nine parts:

  • Four corners: never scale
  • Top and bottom edges: stretch or repeat horizontally
  • Left and right edges: stretch or repeat vertically
  • Centre: stretches in both directions, or is left empty

Where you already use it

CSS border-image takes an image and slice values and does exactly this for any element. Android's 9-patch format (.9.png) marks the stretchable areas with one-pixel guides. Unity and other game engines support 9-slicing for sprites, which is why game menus and dialog boxes can resize without redrawing art. Some animation tools extend the idea to vector artwork, sometimes with more than three slices per axis.

When to use it

Use nine-slice for decorated containers whose size depends on content or screen: game UI panels, chat bubbles, badges, tooltips with ornate borders, buttons with textured edges. For plain shapes, a vector rectangle with a corner radius is simpler and sharper.

Tips for good results

Keep the stretchable edges simple, such as flat colour or a pattern that tiles. Gradients across the stretch direction will smear. Test the smallest size the container can reach: if the content is smaller than the corners combined, the corners overlap. On high-density screens, use vector art or provide raster images at 2x and 3x.

Key Principles to Remember

  • Corners fixed, edges stretch in one direction, centre in two
  • Supported by CSS border-image, Android 9-patch and game engines
  • Best for decorated containers that resize with content
  • Keep stretched areas simple and test the minimum size

Frequently Asked Questions

Sources

  1. border-image — MDN Web Docs
  2. Create resizable bitmaps (9-patch files) — Android Developers
  3. 9-slicing — Unity Manual
  4. Nine-slice scaling — Wikipedia

Related Guides & Examples

Vector UI that scales

Open interactive components built from vector shapes and see how they hold up at any size.

Browse components
Try for free