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

> 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.

Updated November 2026. Source: https://www.exodeui.com/learn/nine-slice-scaling/

## Key takeaways

- 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

## 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.

## Frequently asked questions

### What is a 9-patch image?

Android's nine-slice format: a PNG with one-pixel guide lines that mark which parts stretch and where content goes.

### How do I do nine-slice scaling in CSS?

Use border-image with border-image-slice values that define the corners, and border-image-repeat to stretch or tile the edges.

### Is nine-slice the same as N-slicing?

N-slicing generalises the idea to more than three slices per axis, so more parts can stay fixed while others stretch.

### Does nine-slice work with vector graphics?

Yes, in tools that support it. Vector art stays sharp at any size, which avoids the blurry edges of stretched raster images.

## Related

- [Best game UI animation tools](https://www.exodeui.com/best-game-ui-animation-tools/)
- [Responsive animation layouts](https://www.exodeui.com/learn/responsive-animation-layouts/)
- [Vector vs raster UI graphics](https://www.exodeui.com/learn/vector-vs-raster-ui-graphics/)
- [Tooltips UX guidelines](https://www.exodeui.com/learn/tooltips-ux-guidelines/)
