A component that provides a simple column layout
Open your project folder in terminal app.
Run npm install @devvit/kit --save
Add the line import { Columns } from '@devvit/kit';
in the beginning of the component file.
Add Columns
element to any component in your app like in examples below:
<Columns columnCount={2} gapX="5px" gapY="10px" order="column">
<hstack backgroundColor="grey">
<text>Birds</text>
</hstack>
<hstack>
<text>Raven</text>
</hstack>
<hstack>
<text>Parrot</text>
</hstack>
<hstack backgroundColor="grey">
<text>Dogs</text>
</hstack>
<hstack>
<text>Bulldog</text>
</hstack>
<hstack>
<text>Poodle</text>
</hstack>
</Columns>
<Columns columnCount={2} gapX="5px" gapY="10px" order="column">
{participants.map(participant => {
return (
<hstack border="thin" alignment="center middle">
<text>{participant}</text>
</hstack>
);
})}
</Columns>
Number of columns to render.
Optional limit for number of rows.
Specifies the logic of item distribution.
"column"
: items are split evenly between all columns."column-fill"
: fill each column to its maximum (specified bymaxRows
) before filling the next."row"
: fill each row to it's maximum (specified bycolumnCount
) before filling the next.
columnCount={3} maxRows={4} order={...}
1 4 6
2 5 7
3 _ _
1 5 _
2 6 _
3 7 _
4 _ _
1 2 3
4 5 6
7 _ _
Optional horizontal gap between items (in pixels).
Optional vertical gap between items (in pixels).