You drop a panel sprite into a NinePatchRect, drag it out to the size of a dialogue box, and something is off. The border is soft, its pattern is pulled into dashes, or the corners run together when the box gets small.
Every property name and default below was read from Godot 4.7.2, and every result was measured: we rendered the panels and read each pixel back. The main test panel is frame_wood from the Farm RPG, 24x24 with margins of 8, next to a 24x24 test panel with a rivet every 4 px along its edges. If 9-slice is new to you, start with what 9-slice scaling is.
The four patch margins
patch_margin_left, patch_margin_top, patch_margin_right and patch_margin_bottom are whole pixels counted in from each side of the texture. All four default to 0, so nothing is protected until you set them. The left and top margins make the top-left corner, drawn exactly as it is; between two corners is an edge, and the middle is the centre.
With all four at 8, a 96x60 frame_wood panel kept its 8x8 corners pixel for pixel. In code:
- var panel := NinePatchRect.new()
- panel.texture = preload("res://ui/frame_wood.png")
- panel.patch_margin_left = 8, and the same for top, right and bottom
- panel.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
- panel.size = Vector2(96, 60)
The margins also set the smallest size: left plus right by top plus bottom. That was 16x16 for frame_wood and 12x10 for the Farm RPG name plate (margins 6, 5, 6, 5). A size of 4x4 stayed 16x16, so the corners can't overlap.
Stretch, Tile or Tile Fit
axis_stretch_horizontal and axis_stretch_vertical are each Stretch (the default), Tile or Tile Fit, and what they do depends on the edge.
A flat edge looks the same in all three. The Farm RPG's four frames and its name plate have edges that are the same along their length and one-colour centres. At 101x47 (101x23 for the name plate), Tile and Tile Fit drew exactly the same pixels as Stretch.
A patterned edge doesn't. Our rivet panel at 50x40 has 34 px between its corners to fill with an 8 px piece holding two rivets:
- Stretch pulled the piece to 34 px, so its rivets became 5 px dashes.
- Tile kept every rivet 1 px wide and 4 px apart, but 34 isn't a multiple of 8: the last copy was cut after 2 px, leaving two rivets 2 px apart beside the right corner.
- Tile Fit squeezed in 4 whole copies. Nothing was cut, but the gaps went 4, 5, 4, 4, 4, 5 and 4 px.
At 56x40 (40 px between the corners) Tile and Tile Fit were identical, every gap 4 px. So: Stretch for flat edges, Tile for patterned ones with the inside a multiple of the pattern.

draw_center and region_rect
draw_center is on by default. Turn it off and only the frame is drawn: all 3,520 pixels inside the margins showed what was behind the panel. That suits a frame over a portrait or a minimap.
region_rect defaults to Rect2(0, 0, 0, 0), the whole texture. For a panel on a sprite sheet, set it to the panel's rectangle; the margins then count from its sides. We put the rivet panel on a 64x32 sheet with magenta all round it:
- With Nearest, no magenta got in, at 1x or 2.5x.
- With Linear at 2.5x, 358 pixels on the panel's outer edge took in the magenta and turned purple.
- Tile Fit on the region at 50x40 drew a 1 px dark line down the centre where two copies met. The panel from its own file didn't.
The Pixel UI Kit sheets come with a JSON map of each sprite's position, 9-slice margins and content area, so region_rect and the margins can be typed straight from it.
Why the panel blurs
texture_filter defaults to Parent Node. When no parent sets it, the viewport's default is used, and the game window takes that from Project Settings, Rendering, Textures, Canvas Textures, Default Texture Filter: Linear in Godot 4.7.2.
At 1x the default drew frame_wood clean. Scaled to 3x, it drew 6,592 pixels in 151 colours that aren't in the art; on Nearest, none. Linear also hurt at 1x once it had a pattern to stretch: the rivet panel got 232 blended pixels.
Set Default Texture Filter to Nearest for the project, or texture_filter to Nearest on the node or a parent of your UI.
Half-pixel positions are less of a risk. Project Settings, GUI, Common, Snap Controls to Pixels is on by default, and a panel at x 8.5 was drawn exactly as at 9, even on Linear. With the snap off, Linear at 8.5 blended 1,708 pixels into 42 new colours.
Why it looks uneven when scaled
Nearest never makes new colours, but at a scale that isn't a whole number the texels can't all be the same width. At a node scale of 2.5, frame_wood's 1 px outline came out 3 px at the top and left, 2 px at the bottom and right, and the rows inside alternated 3 and 2 px. At 3x every outline was 3 px.
Scaling the window does the same. Display, Window, Stretch has Mode (default disabled), Aspect (keep) and Scale Mode (fractional). We set Mode to canvas_items with a 320x180 base in an 800x450 window, a 2.5x scale:
- The Nearest panel had a 3 px left outline and a 2 px right one. Moved one base pixel at a time, it stepped 2, 3 and 2 screen pixels.
- A panel beside it on the default filter had 10,696 pixels in 188 colours that aren't in the art.
- With Scale Mode integer, the scale dropped to 2x: 640x360 with borders of 80 px at the sides and 45 px top and bottom. Every outline was 2 px and the Nearest panel had no new colours. The default-filter panel still had 6,832 blended pixels.
A sharp pixel UI needs both: Nearest and a whole-number scale.
StyleBoxTexture for Panel and Button themes
Buttons and panels draw styles, and StyleBoxTexture is the same 9-slice as a style: texture_margin_left, texture_margin_top, texture_margin_right and texture_margin_bottom (default 0), plus the same axis stretch, draw_center and region_rect. A Panel with frame_wood as its panel style drew the same pixels as the NinePatchRect, as an override and through a Theme with set_stylebox("panel", "Panel", style).
Two things work differently:
- A Panel's minimum size stayed 0x0, so it accepted 10x10 and drew a lopsided frame with its corners run together. A PanelContainer with the same style had a 16x16 minimum. Use one, or give the Panel a custom_minimum_size.
- The content margins default to -1, and then the texture margins place the contents. A Button saying OK had a 23x23 minimum with an empty style, 39x39 with frame_wood, and 31x31 with content margins of 4.
For sharp text inside the frame, see bitmap pixel fonts in Godot 4.

Checklist
- Margins are the corner sizes in texture pixels; the minimum size is left plus right by top plus bottom.
- Flat edges: Stretch. Patterned edges: Tile, with the inside a multiple of the pattern.
- region_rect for a panel on a sheet, with Nearest so its neighbours stay out.
- Default Texture Filter: Nearest. Snap Controls to Pixels: on.
- Scale the window by a whole number: Scale Mode integer.
- For themes, StyleBoxTexture with the same margins, plus a PanelContainer or a minimum size.
Frames ready to slice
The Pixel UI Kit has 245 sprites in each of 6 themes, 21 of them panels: 9-slice panels and windows, a dialogue box, speech bubbles and tooltips, with a README holding the 9-slice guide. Cozy UI has 3 themes of 40 pieces plus 50 icons, with 9-slice margins in a JSON and flat middle rows and columns. Since Update 34 (December 6, 2026) the Farm RPG has 24x24 frames (wood, dark and leaf with margins of 8, paper with 4) and a 24x16 name plate (6, 5, 6, 5), all listed in its ui.json.
All three can go in commercial games but can't be resold as files; see can I use game assets in a commercial game. Cozy UI and the Farm RPG ask for a credit, "Art by Gridwright", with a link; the Pixel UI Kit is older and needs none.
All three are in the $20 bundle shown on this page, with the rest of our packs and tools. If your game needs frames in its own style, you can order a custom pack.