Skip to content
CleverKeys Wiki

Layout XML Reference

A CleverKeys layout file describes the keys and, optionally, how the keyboard looks while that layout is active: a whole theme (colours for light and dark mode, key gaps, corners, shadows, hints, key-press preview) and per-row or per-key colours and gaps. Everything is optional: a layout without styling looks like your chosen theme, exactly as before.

Paste or import a file in Settings > Layout Manager > Add Layout > Custom (see Custom Layouts). The editor checks the file: values it cannot use are listed and Save stays disabled until they are fixed. A layout that reaches the keyboard some other way (a backup, an older file) still loads; values it cannot use are skipped.

Quick Summary

WhatDescription
Elements<keyboard> (root), <theme> with <light> / <dark>, <row>, <key>, <modmap>
Own theme<theme> inside <keyboard>; anything it leaves out comes from your global theme
Per-key styleColour and gap attributes on <key>, or on <row> for all its keys
Keep itLayout Manager > Save theme as custom theme puts the layout’s theme in Theme Manager
Share itTheme Manager > Export as layout XML; Layout Manager > Export XML

Which setting wins

Theme (colours and look), most specific first:

  1. the theme you pick with the layout’s Theme chip in Layout Manager;
  2. the theme="…" attribute on <keyboard> (a theme ID);
  3. the layout’s own <theme> element;
  4. your global theme (Theme Manager).

Follow global theme on the Theme chip skips 2 and 3. Layout’s own theme (offered when the file has a <theme> and no theme="…") uses 3. If 1 or 2 names a theme that is not on this device, the layout’s own <theme> is used, else the global theme. Fields the <theme> leaves out are taken from your global theme in the current light/dark mode, so changing your global theme also changes them.

Key gaps and borders, most specific first:

  1. the attribute on <key>;
  2. the attribute on its <row>;
  3. the layout’s Key spacing & borders chip in Layout Manager;
  4. the key_* attributes on <keyboard>;
  5. the <theme> (or the bound theme, if it is a familiar look);
  6. Settings > Appearance.

Your Appearance settings are never changed by a layout.

<keyboard> (root)

AttributeValueMeaning
nametextName shown in Layout Manager; also the name a saved custom theme gets.
scriptlatin, cyrillic, persian, …Script of the letters; needed for CTC swipe (see Custom Layouts).
numpad_scriptscript nameScript of the number pane (default: script).
bottom_rowtrue (default) / falseAdd CleverKeys’ standard bottom row.
embedded_number_rowtrue / false (default)The layout has its own number row; none is added.
locale_extra_keystrue (default) / falseAdd the language’s extra keys.
numpad_heighttrue / false (default)Opt in to Scale numpad height.
symbolsbuilt-in pane name (symbols_samsung_1)The pane a switch_symbols key opens instead of CleverKeys’ number pane (QWERTY (Samsung-style)‘s two pages; each page names the next). Without it switch_symbols opens the number pane.
widthnumberTotal width in key units (default: the widest row).
languagelanguage code (de, fa, pt_br)Default language binding.
themetheme ID (rosepine, look_gboard, custom_…)Default theme binding (beats <theme>).
key_horizontal_gap0–5Horizontal key gap, in the Appearance slider’s unit.
key_vertical_gap0–5Vertical key gap, in the Appearance slider’s unit.
key_bordertrue / falseDraw the custom border (radius and width below) or the theme’s own frame.
key_border_radius0–100Corner radius, percent of the key width.
key_border_width0–10Border line width in dp.

<theme>

One <theme> element, anywhere inside <keyboard> (a second one is ignored). Every attribute is optional. Colours are #RRGGBB or #AARRGGBB (alpha first; #00… is fully transparent).

Colours

The same colour attributes are allowed on <theme> (both modes), <light> and <dark> (replacing the <theme> value while the system is in that mode).

AttributeColours…If left out
keyletter-key fillglobal theme
key_pressedfill of a pressed keyglobal theme
key_lockedfill of Caps Lock and other locked modifiersglobal theme
key_modifierfill of Shift, Ctrl, Altglobal theme
key_specialfill of Backspace, 123, emoji and other function keysglobal theme
labelkey labelsglobal theme
sub_labelcorner labels (gesture hints)global theme
secondary_labeldimmed labels of function keysglobal theme
border_colorkey outlineglobal theme
border_color_pressedoutline of a pressed keyglobal theme
swipe_trailswipe trailyour swipe-trail colour
ripplepress feedback in the suggestion barglobal theme
bar_textsuggestion textglobal theme
bar_backgroundsuggestion barglobal theme
bar_highlightthe suggestion space will commitglobal theme
keyboard_backgroundbehind the keysglobal theme
surfacepop-up panels of the suggestion barglobal theme
label_pressedlabel of a pressed keyglobal theme
locked_labellabel on Caps Lockglobal theme
enter_keyplain Enter fillkey_special
enter_labellabel on plain Enternormal labels
action_keyEnter replaced by Go / Search / Send / Donekey_special
action_labellabel on the action keynormal labels
modifier_labellabels on modifier and function keysnormal labels
key_shadowshadow under each key (drawn when shadow_dy > 0)none
bar_separatorlines between suggestions (#00FFFFFF = none)sub-label colour, faint
popupkey-press preview and long-press panelkey
popup_labellabel in the preview and panellabel
popup_selectedselected long-press alternativekey_locked
popup_selected_labelits labellocked_label
latched_keyShift latched for one letter (tapped once, or capitalising a sentence start)key_pressed
latched_labelits label / icon (drawn only with latched_key)normal labels

Shape and size

AttributeValueMeaning
gap_horizontal0–0.5Gap between keys, as a fraction of one key’s width.
gap_vertical0–0.5Gap between rows, as a fraction of the row height.
corner_radius0–64 (dp)Key corner radius.
border_width0–8 (dp)Key outline width (0 = none).
shadow_dy0–8 (dp)How far below each key its key_shadow is drawn (0 = none).
label_scale0.5–2Label size relative to your label size setting.
label_weight100–900Label font weight (400 regular, 700 bold; Android 9+).
function_label_scale0.5–2Size of the function keys’ text labels (!#1, ABC, 1/2, 123) relative to CleverKeys’ size for them (three quarters of a letter); icons keep their size. Samsung-style uses 1.25, about as large as One UI draws them.

Gaps here are relative so they fit any keyboard height; the key_* gaps on <keyboard>, <row> and <key> use the Appearance slider’s unit and win over these.

Hints, keys and preview

AttributeValueMeaning
hintsall / digits / noneWhich corner labels are drawn (gestures always work). Appearance > Show gesture hints on familiar looks draws them all.
hint_size0.1–1Corner-label size as a fraction of the main label.
hint_weight100–900Corner-label font weight.
pill_keysany of enter, action, numbers (space-separated; empty = none)Keys drawn fully rounded.
letter_keysemojiDraw the emoji key like a letter key.
function_charsup to 16 characters, e.g. ,.Characters drawn with the function-key colours.
previewnone / bubble / balloon / column / plateKey-press preview shape (Appearance > Key-press preview on familiar looks turns previews off).
preview_width0.5–3Preview width in key widths (needs preview).
preview_height0.5–3Preview height in key heights.
preview_label_scale0.5–3Preview label size relative to the key’s label.
preview_corner0–1Preview corner radius as a fraction of the key height.
preview_shadowtrue / falseSoft shadow under the preview.
dynamic_colortrue / falseFollow the wallpaper colours on Android 12+ (Material You); the colours above are the fallback.
bar_slots1–5Show the suggestion bar as this many equal slots instead of scrolling suggestions, like the familiar keyboards (they use 3). Suggestions that do not fit are not shown.
bar_centretrue / falseWith bar_slots: put the best suggestion — the one space types — in the centre slot and the word you typed left of it (default true); false fills the slots left to right.
bar_quote_typedtrue / falseWith bar_slots: show the word you typed in quotation marks when it is not the best suggestion, as iOS does (default false).
bar_emphasiscommit / centreWith bar_slots: commit (default) draws the centre bold in the highlight colour only while it is what space types, as Gboard does (next-word suggestions stay plain); centre always draws the centre in the text colour and dims the side slots, as SwiftKey does.
action_iconskind:icon pairsDraw the action key (it replaces Enter in Go / Search / Send / Next / Done / Previous fields) as an icon instead of its word. Kinds go, search, send, next, done, previous, and enter for plain Enter; icons arrow, search, send, send_outline, next, previous, done, return, arrow_up (CleverKeys’ own line icons). An action not listed shows its word.
action_accentkindsThe actions drawn in the action_key / action_label colours; the others use the Enter key’s (enter_key / enter_label). Leave it out for all; "" for none (Gboard).
action_lowercasetrue / falseShow the action’s word in lower case (“go”, “search”), as iOS 18 does (default false).
action_icon_scale0.5–2Size of the action-key icons relative to CleverKeys’ default (Samsung-style uses 1.3).
space_languagetrue / falsePrint the current language on the space bar (“English (US)”), as Samsung Keyboard does (default false). Appearance → “Language name on the space bar” turns it off everywhere.
key_legendskey:text or key:@mic entries, space-separatedA small mark at the top of a key in place of its gesture hints, as SwiftKey draws a microphone over the comma and ,!? over the period (SwiftKey-style: ,:@mic .:,!?). Text is 1–4 characters without spaces; @mic is CleverKeys’ voice icon and is drawn only when the key has a voice-input swipe, a text mark only when the key has any swipe. Hidden while every gesture hint is drawn (hints="all", or Show gesture hints on familiar looks). "" = none.
shift_filledtrue / falseDraw Shift as a filled arrow while shifted, and a filled arrow over a bar in Caps Lock, as Gboard does (CleverKeys’ own icon; default false, the outline glyph).
nametextName for the theme when it is saved or exported.

<row>

AttributeValueMeaning
heightnumber ≥ 0.5 (default 1)Row height in row units.
shiftnumber ≥ 0Empty space above the row.
scalenumberStretch the row’s keys to this total width.
stylingsee belowDefault styling for every key of the row.

<key>

AttributeValueMeaning
c or key0key valueThe key’s main value (letter, shift, space, label:action, …).
nw ne sw se w e n s (or key1–key8)key valueSwipe-direction values (loc … only when that key is enabled).
anticirclekey valueValue of the anticlockwise circle gesture.
widthnumber (default 1)Key width in key units.
shiftnumberEmpty space to the left of the key.
indicationtextSmall text printed on the key.
stylingsee belowThis key’s own styling (beats its row’s).

Styling attributes (<key> and <row>)

AttributeValueMeaning
key_horizontal_gap0–5This key’s horizontal gap (Appearance slider unit).
key_vertical_gap0–5This key’s vertical gap.
key_bordertrue / falseCustom border on, or the theme’s own frame.
key_border_radius0–100Corner radius, percent of the key width.
key_border_width0–10 (dp)Border line width.
key_backgroundcolourFill at rest.
key_background_pressedcolourFill while pressed.
key_border_colorcolourOutline colour.
key_label_colorcolourLabel colour at rest.
key_label_color_pressedcolourLabel colour while pressed.

A key’s own gap changes only how large its key is drawn inside its place on the keyboard: where you touch, and the key positions swipe typing uses, stay exactly the same.

Key and row colours are the same in light and dark mode; only the <theme> (with its <light>/<dark> children) changes with the mode. A key that sets key_background but no key_label_color keeps the theme’s label colour for the current mode, which can vanish on a fixed background (a light fill under dark mode’s light labels). Set key_label_color together with key_background, and pick colours that read in both modes. A latched Shift or other modifier keeps its key_label_color on the pressed fill, so give such a key a key_background_pressed (and key_label_color_pressed) too.

<modmap>

Optional remapping of keys under a modifier: <modmap><shift a="a" b="A"/></modmap>; children <shift>, <fn> or <ctrl>, each with a (the key) and b (what it becomes).

Saving and sharing a layout’s theme

  • Layout Manager > Save theme as custom theme (shown for a layout with a <theme>) stores it as a custom theme named after the layout. Anything the <theme> left out is filled in from your current global theme, so the custom theme looks exactly like the layout did. It appears in Theme Manager under Custom, can be selected or bound to other layouts, and opens in the Theme Creator, whose Keyboard Look section edits every field above.
  • Theme Manager > Export as layout XML (the share button on a custom theme or a familiar look) writes that theme as a <theme> element to paste into a layout.
  • Layout Manager > Export XML, for a layout whose theme is a custom theme, can include it as the file’s <theme> (Include the layout’s custom theme in the file). The theme="…" binding is kept: on another device without that custom theme, the included copy is used.
  • Saving a layout’s theme and exporting it again gives back every value the <theme> had.

Worked example

This complete layout uses every element and styling attribute. It is also the file the app’s tests load (docs/wiki/layouts/examples/harbour.xml).

<?xml version="1.0" encoding="utf-8"?>
<!-- Harbour: a complete example of a self-styled CleverKeys layout.
     Reference: docs/wiki/layouts/layout-xml-reference.md. Paste it into
     Settings > Layout Manager > Add Layout > Custom, or import the file there.
     Every attribute of <theme>, <row> and <key> styling is used at least once. -->
<keyboard name="Harbour" script="latin" bottom_row="false"
          key_horizontal_gap="1.2" key_vertical_gap="1.5"
          key_border="true" key_border_radius="18" key_border_width="1">
  <theme
      name="Harbour"
      key="#FFFFFF"
      key_pressed="#C9D6E3"
      key_locked="#1F6FB2"
      key_modifier="#D7E2EC"
      key_special="#D7E2EC"
      label="#102A43"
      sub_label="#52667A"
      secondary_label="#52667A"
      border_color="#B8C7D6"
      border_color_pressed="#1F6FB2"
      swipe_trail="#1F6FB2"
      ripple="#C9D6E3"
      bar_text="#102A43"
      bar_background="#E8EEF4"
      bar_highlight="#1F6FB2"
      keyboard_background="#E8EEF4"
      surface="#FFFFFF"
      label_pressed="#102A43"
      locked_label="#FFFFFF"
      enter_key="#1F6FB2"
      enter_label="#FFFFFF"
      action_key="#E07A1F"
      action_label="#FFFFFF"
      modifier_label="#243B53"
      key_shadow="#33102A43"
      bar_separator="#00FFFFFF"
      popup="#FFFFFF"
      popup_label="#102A43"
      popup_selected="#1F6FB2"
      popup_selected_label="#FFFFFF"
      latched_key="#174F80"
      latched_label="#FFFFFF"
      gap_horizontal="0.12"
      gap_vertical="0.16"
      corner_radius="10"
      border_width="0"
      shadow_dy="1"
      label_scale="1.15"
      label_weight="500"
      function_label_scale="1"
      function_chars=",."
      hints="digits"
      pill_keys="enter action"
      letter_keys="emoji"
      preview="bubble"
      preview_width="1.3"
      preview_height="1.25"
      preview_label_scale="1.2"
      preview_corner="0.2"
      preview_shadow="true"
      hint_size="0.4"
      hint_weight="400"
      dynamic_color="false"
      bar_slots="3"
      bar_centre="true"
      bar_quote_typed="false"
      bar_emphasis="commit"
      action_icons="go:arrow search:search send:send next:next done:done previous:previous enter:return"
      action_accent="search send"
      action_lowercase="false"
      action_icon_scale="1"
      space_language="false"
      key_legends=""
      shift_filled="false">
    <light keyboard_background="#E8EEF4" bar_background="#E8EEF4"/>
    <dark key="#1C2B3A" key_pressed="#2E4458" key_modifier="#132130" key_special="#132130" label="#E6EEF5" sub_label="#9FB3C8" secondary_label="#9FB3C8" border_color="#2E4458" bar_text="#E6EEF5" bar_background="#0B1621" bar_highlight="#7FB8E6" keyboard_background="#0B1621" surface="#1C2B3A" label_pressed="#E6EEF5" modifier_label="#D9E2EC" popup="#2E4458" popup_label="#E6EEF5"/>
  </theme>
  <row>
    <key c="q" ne="1"/>
    <key c="w" ne="2"/>
    <key c="e" ne="3" se="loc €"/>
    <key c="r" ne="4"/>
    <key c="t" ne="5"/>
    <key c="y" ne="6"/>
    <key c="u" ne="7"/>
    <key c="i" ne="8"/>
    <key c="o" ne="9"/>
    <key c="p" ne="0"/>
  </row>
  <row>
    <key shift="0.5" c="a"/>
    <key c="s"/>
    <key c="d"/>
    <key c="f" key_label_color="#3A86C8"/>
    <key c="g"/>
    <key c="h"/>
    <key c="j" key_label_color="#3A86C8"/>
    <key c="k"/>
    <key c="l"/>
  </row>
  <row key_background="#3E6A93" key_border_color="#9FB3C8" key_label_color="#FFFFFF">
    <key width="1.5" c="shift" nw="home" ne="end" sw="loc capslock" key_background="#1F6FB2"
         key_background_pressed="#174F80" key_label_color_pressed="#FFFFFF"/>
    <key c="z"/>
    <key c="x"/>
    <key c="c"/>
    <key c="v"/>
    <key c="b"/>
    <key c="n"/>
    <key c="m"/>
    <key width="1.5" c="backspace" nw="delete_last_word" ne="delete" key_background="#1F6FB2"/>
  </row>
  <row height="0.95" key_vertical_gap="2">
    <key width="1.5" c="?123:switch_numeric" nw="ctrl" ne="fn" sw="loc switch_greekmath"/>
    <key c=","/>
    <key c="switch_emoji" nw="loc change_method" ne="config" sw="loc switch_clipboard" se="switch_gif"/>
    <key width="4" c="space" n="loc switch_forward" s="loc switch_backward" w="cursor_left" e="cursor_right" key_horizontal_gap="0.6"/>
    <key c="." nw="'" n="\?" ne="!" sw="-" se=":"/>
    <key width="1.5" c="enter" ne="action" n="up" s="down" w="left" e="right"
         key_border="false" key_background_pressed="#174F80" key_label_color_pressed="#FFFFFF"/>
  </row>
</keyboard>

What it does: white letter keys on a light blue-grey background (dark navy in dark mode), a blue Enter (and orange in Go / Search / Send fields), Gboard-like digit hints on the top row, a bubble preview, f and j with blue labels, the third row in steel blue with white labels and a blue-grey outline (Shift and Backspace in the Enter key’s blue, a latched Shift dark blue; these colours read in both modes), a taller gap above the bottom row, a slightly wider space bar frame and an Enter key without the custom border that turns dark blue while pressed.