Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/grammy/mod.ts>Keyboard#toFlowed

The Telegram Bot Framework.
Very Popular
Latest
method Keyboard.prototype.toFlowed
import { Keyboard } from "https://deno.land/x/grammy@v1.32.0/mod.ts";

Creates a new keyboard with the same buttons but reflowed into a given number of columns as if the buttons were text elements. Optionally, you can specify if the flow should make sure to fill up the last row.

This method is idempotent, so calling it a second time will effectively clone this keyboard without reordering the buttons.

Here are some examples.

original    flowed
[  a  ]  ~> [  a  ]    (4 columns)

            [  a  ]
[a b c]  ~> [  b  ]    (1 column)
            [  c  ]

[ a b ]     [a b c]
[ c d ]  ~> [ d e ]    (3 columns)
[  e  ]

[ a b ]     [abcde]
[  c  ]  ~> [  f  ]    (5 columns)
[d e f]

[a b c]     [  a  ]
[d e f]  ~> [b c d]    (3 colums, { fillLastRow: true })
[g h i]     [e f g]
[  j  ]     [h i j]

Parameters

columns: number

Maximum number of buttons per row

optional
options: FlowOptions = [UNSUPPORTED]

Optional flowing behavior