Skip to content

List

Create a list of children with text between each child. The text to join with is specified by providing either joiner children, or providing boolean props for the punctuation and line breaks. The default joiner is no punctuation and a hard break. The ender prop can provide text to place at the end of the list when there is at least one child.

import { List } from "@alloy-js/core";
<List
comma
doubleHardline
ender={Children}
enderPunctuation
hardline
joiner={Children}
line
literalline
semicolon
softline
space
>
{children}
</List>
childrenoptional Children
commaoptional booleanPlace a comma between each element
doubleHardlineoptional booleanPlace two hardlines between each element
enderoptional ChildrenText to place at the end of the list when there is at least one item. If set to true, the joiner is used.
enderPunctuationoptional booleanPlace the join punctuation at the end, without a line break. The punctuation is emitted unconditionally in flat and broken modes. To add trailing punctuation only in broken mode, use ender with <ifBreak> inside a <group> with a non-hardline joiner (e.g. line):
<group>
  <List comma line ender={<ifBreak>,</ifBreak>}>...</List>
</group>
hardlineoptional booleanPlace a hardline (<hbr />) between each element
joineroptional ChildrenText to place between each element
lineoptional booleanPlace a regular line (<br />) between each element
literallineoptional booleanPlace a literal line (<lbr />) between each element
semicolonoptional booleanPlace a semicolon between each element
softlineoptional booleanPlace a softline (<sbr />) between each element
spaceoptional booleanPlace a space between each element