Skip to content

Block

Create an indented block of source text. The block has opener text which is added prior to the block, which defaults to "{", and closer text which is added after the block, which defaults to "}".

import { Block } from "@alloy-js/core";
<Block closer="string" inline newline opener="string">
{children}
</Block>
childrenoptional ChildrenThe block’s contents
closeroptional stringThe closing punctuation of the block. Defaults to ”}“.
inlineoptional booleanIf true the block will not indent the content into new lines
newlineoptional booleanWhether the block starts on a new line. When true, a hardline is added prior to the block. If inline is true, this will only apply if the block is also split due to breaking.
openeroptional stringThe opening punctuation of the block. Defaults to ”{”.

When children is empty, Block renders as {} (opener immediately followed by closer) with no indented content — no explicit empty check is needed before passing children.

// Safe even when props.members is empty — renders `{}`
<Block>{props.members}</Block>