Sidechair

box.set_text_size()

Browse the reference

Changes the type size of the text inside a box to one of the named size constants.

Try it in the editor

Pick size.tiny, size.small, size.normal, size.large, size.huge or size.auto. The size applies to the whole string. size.auto lets the text scale with the box, while a fixed size stays the same however the box is resized.

A larger size needs a wider and taller box to stay readable, so choose the size from the width of the zone, as in the example.

Syntax

Pine Script
box.set_text_size(id: series box, text_size: series int/string) -> void
box.set_text_size(text_size: series int/string) -> void

Arguments

NameTypeDefaultDescription
idseries boxrequiredThe box whose text size changes.
text_sizeseries int/stringrequiredSize constant: size.auto, size.tiny, size.small, size.normal, size.large or size.huge. It applies to the whole text of the box.

Returns

Nothing.

Remarks

  • On Sidechair: size.auto is a fixed 11 pixels and does not scale with the box. The named sizes are 9 pixels for tiny, 10 for small, 12 for normal, 15 for large and 19 for huge, and a number given instead of a constant falls back to auto.

Example

Pine ScriptLarger text once the box is wideOpen in editor
//@version=6
indicator("box.set_text_size: size by width", overlay = true)
var box z = box.new(bar_index, high, bar_index + 1, low, bgcolor = color.new(color.teal, 85), text = "Range", text_color = color.white)
box.set_right(z, bar_index)
box.set_text_size(z, box.get_right(z) - box.get_left(z) > 100 ? size.large : size.small)

See also

Runs on Sidechair