OneScript

background

Draw a shape style behind a view.

background(style) draws a ShapeStyle behind the result produced by the preceding modifiers. Colors, gradients, and materials are supported.

import { Color, Modifier, Text } from "onescript/views"

<Text modifier={Modifier
  .padding(12)
  .background(Color.systemGray6)}>
  Hello
</Text>

Order controls the painted area:

// The background includes the padding.
<Text modifier={Modifier
  .padding(12)
  .background("#F2F2F7")}>Hello</Text>

// The padding is outside the background.
<Text modifier={Modifier
  .background("#F2F2F7")
  .padding(12)}>Hello</Text>

See ShapeStyle for all supported styles and Color for color values.

How is this guide?

Last updated on