vadimdemedes/ink

Support `Box` background color

isaacs opened this issue · 2 comments

isaacs commented

It'd be nice if <Box> could take a backgroundColor property. Currently to render a box with a background color, you have to figure out the max length of all the lines in the box, and create appropriately padded <Text> components, which is a bit of a pain.

The background of a <Box> should be smart enough to restore after a <Text> that sets the background color, so for example:

<Box backgroundColor="blue" paddingY={2} width={1}>
  <Text backgroundColor="red">x</Text>
</Box>

would render an x on a red background, surrounded by 1 block of blue around it.

Old version of Ink used to have this, but it had many issues, so I ended up removing this feature altogether in Ink 3. Might give it another shot again though, but can't promise any ETA.

This function feels very useful. I want to highlight the entire row. How should this be achieved?

image