MeshGradient

A two-dimensional gradient defined by a 2D grid of positioned colors.

ComponentiOS 18.0+macOS 15.0+tvOS 18.0+visionOS 2.0+watchOS 11.0+MeshGradient in SwiftUI

Declaration

React
import { MeshGradient } from 'swiftui-react-native';
Swift
nonisolated struct MeshGradient

Initializers

5 SwiftUI initializers back <MeshGradient>. The props you pass pick one.

React
<MeshGradient
  width: number
  height: number
  bezierPoints: SwiftUI.MeshGradientBezierPoint[]
  colors: SwiftUI.Color[]
  background?: SwiftUI.Color
  smoothsColors?: boolean
  colorSpace?: SwiftUI.GradientColorSpace
/>
Swift
@export(implementation) nonisolated init(
    width: Int,
    height: Int,
    bezierPoints: [MeshGradient.BezierPoint],
    colors: [Color],
    background: Color = .clear,
    smoothsColors: Bool = true,
    colorSpace: Gradient.ColorSpace = .device
)
  • width*number

    the width of the mesh, i.e. the number of vertices per row.

  • height*number

    the height of the mesh, i.e. the number of vertices per column.

  • the array of points and control points, containing width x height elements.

  • colors*SwiftUI.Color[]

    the array of colors, containing width x height elements.

  • backgroundSwiftUI.Color

    the background color, this fills any points outside the defined vertex mesh.

    Default `.clear`

  • smoothsColorsboolean

    whether cubic (smooth) interpolation should be used for the colors in the mesh (rather than only for the shape of the mesh).

    Default `true`

  • the color space in which to interpolate vertex colors.

    Default `.device`

Also takes the common view props: modifiers, style and testID.

See also

More in Colors and gradients.