← GuidesFollowing the user's text sizeText in a JsonUI layout grows with the user's text size: Dynamic Type on iOS, the font scale on Android, the browser's font size on the web. A text component can opt out (fontScaling: false) or cap how far it grows (maxFontScale), and an app can set both defaults once.~5 min read
1. Two attributesfontScaling (true or false) and maxFontScale (a number, 1 or more) go on any component that draws text: Label, Button, TextField (also written Input or EditText), TextView, IconLabel, SelectBox, Switch (Toggle), CheckBox (Check), Radio and Segment. Leave both out and the text follows the user's size with no cap — except a Segment's labels: a Segment with no fontSize draws them at 13 and, with neither written, they do not follow the user's size on any platform, as iOS draws a segmented control's. fontScaling: false draws the declared fontSize at that size whatever the user's setting. maxFontScale caps the drawn size at fontSize × maxFontScale, and only counts while the text follows. A component's own declaration wins over the app default (section 3).A price that may grow to 1.5 times, a badge that keeps its size, and a note that follows the user without a cap:• A component that declares either attribute without a fontSize is still held to it, at that component's default size: the iOS and Android generators write the declaration with no size.
layout
{ "type": "View", "orientation": "vertical", "child": [ { "type": "Label", "id": "price", "text": "@{price}", "fontSize": 28, "maxFontScale": 1.5 }, { "type": "Label", "id": "badge", "text": "NEW", "fontSize": 11, "fontScaling": false }, { "type": "Label", "id": "note", "text": "@{note}", "fontSize": 15 } ]}2. What each platform writesThe generators turn the two attributes into code that the libraries read at run time. Here is what the generators write for a Label with fontSize 13 (excerpts).• Web: a size that follows is a rem length, so it grows with the browser's font size. fontScaling: false gives a px length, which does not. maxFontScale gives the px length fontSize × maxFontScale, and the browser draws the smaller of the two. Two CSS custom properties carry the app defaults (section 3). A page that never sets them draws N / 16 rem with no cap.• iOS: the modifier hands the declaration to SwiftJsonUI, which works out the size from the Dynamic Type setting. A cap is rounded down to a Dynamic Type step: the largest step whose ratio to the standard size is at most maxFontScale. That rule was read from SwiftJsonUI's FontScaling.swift, not drawn here.• Android: every size, and the line height with it, goes through KotlinJsonUI's jsonUIFontSize, so the app default reaches a text with no declaration too. KotlinJsonUI says Android 14 and later grow small text more than large text, and the cap applies after that conversion.
generated (excerpts)
Label, fontSize 13 Web (the size class on the element) no declaration text-[length:min(calc(13*var(--jui-font-unit,0.0625rem)),calc(13*var(--jui-font-max,10000px)))] fontScaling: false text-[length:13px] fontScaling: true text-[length:min(0.8125rem,calc(13*var(--jui-font-max,10000px)))] maxFontScale: 1.5 text-[length:min(calc(13*var(--jui-font-unit,0.0625rem)),19.5px)] iOS (SwiftUI) no declaration (nothing added) fontScaling: false .fontScaling(false, maxFontScale: nil) maxFontScale: 1.5 .fontScaling(nil, maxFontScale: CGFloat(1.5)) Android (Compose) no declaration fontSize = jsonUIFontSize(…) fontScaling: false fontSize = jsonUIFontSize(…, fontScaling = false) maxFontScale: 1.5 fontSize = jsonUIFontSize(…, maxFontScale = 1.5f)3. Defaults for the whole appEach platform has one place for two defaults: whether text follows when a component does not say, and the cap for a component that sets none. The settings mean the same on all three. Out of the box, text follows and there is no cap.• Web: configureScaling sets two custom properties on the document root, and the generated sizes read them: --jui-font-unit (0.0625rem while text follows, 1px when it does not) and --jui-font-max (the cap). jui sync_tool places the Configuration template at src/lib/jsonui/Configuration.ts by default.• Every text the web generator writes calls Configuration.Font.resolve, so an app's fontProvider and Configuration.Font.family (the family for text that names none) reach text with no font settings too; iOS does this too, and jsonui-cli says Android does as well. jui build replaces Configuration.ts with the current template when the file is still an earlier template byte for byte, and leaves an edited one alone with an INFO line. The template also maps weight names to CSS weights: a browser drops semibold written into font-weight as it is (measured in headless Chromium).• On the web, a component with neither a fontSize nor a declaration writes no size and inherits the browser's, so scaling: false for the app does not pin it. On iOS, such a text keeps the environment's .body font when no font provider answers for it.
app defaults
// iOSSwiftJsonUIConfiguration.shared.font.maxScale = 2.0// SwiftJsonUIConfiguration.shared.font.scaling = false // stop following // AndroidConfiguration.Font.maxScale = 2.0f// Configuration.Font.scaling = false // Web (the Configuration template, src/lib/jsonui/Configuration.ts by default)Configuration.Font.configureScaling({ maxScale: 2 })// Configuration.Font.configureScaling({ scaling: false })4. Measured in a browserThe four web lengths from section 2, set on elements in headless Chromium and read back with getComputedStyle. 16px is the browser's default root size; 32px stands for a user who doubled it. The two app-default rows set the custom properties to the values configureScaling writes.• The component wins over the app default. With scaling: false for the app, a Label that says fontScaling: true still grows (26px). One that only says maxFontScale stops following (13px), because the cap counts only while the text follows.
computed font-size, headless Chromium
root app default none false true max 1.516px (not set) 13px 13px 13px 13px32px (not set) 26px 13px 26px 19.5px32px scaling: false 13px 13px 26px 13px32px maxScale: 1.5 19.5px 13px 19.5px 19.5px5. What this page measured, and what it did notMeasured: the code the web, iOS and Android generators write for a Label under each declaration (rjui's LabelConverter, sjui's ConverterFactory and kjui's ComposeBuilder, called directly), and the web lengths in headless Chromium. Read from source, not run: SwiftJsonUI's FontScaling.swift and KotlinJsonUI's Configuration.kt. No app ran on a device or simulator, and no Dynamic Type or Android font scale setting was changed here. That the three platforms draw the same sizes at a text scale of 2.0 is jsonui-cli's conformance measurement. The provider bullet in section 3 was measured with rjui's LabelConverter and this site's own build.
Keep reading
Writing layoutsfontSize, styles and the rest of a layout these attributes sit in./guides/writing-layouts
Screen readersThe other accessibility attributes: names and live regions./guides/screen-readers
Label referenceEvery Label attribute, fontScaling and maxFontScale included./reference/components/label