> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metabind.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# LinearGradient

> A gradient that transitions between colors along a straight line between two points.

export const PlatformStatuses = ({statuses}) => {
  const StatusBadge = ({status, label}) => {
    const styles = {
      green: {
        backgroundColor: '#dcfce7',
        color: '#166534'
      },
      orange: {
        backgroundColor: '#fed7aa',
        color: '#9a3412'
      },
      red: {
        backgroundColor: '#fecaca',
        color: '#991b1b'
      },
      gray: {
        backgroundColor: '#f3f4f6',
        color: '#4b5563'
      }
    };
    const baseStyle = {
      display: 'inline-flex',
      alignItems: 'center',
      padding: '0.125rem 0.625rem',
      borderRadius: '9999px',
      fontSize: '0.875rem',
      fontWeight: '500'
    };
    const colorStyle = styles[status] || styles.green;
    return <span style={{
      ...baseStyle,
      ...colorStyle
    }}>
        {label || status}
      </span>;
  };
  const STATUS_CONFIG = {
    supported: {
      label: "Supported",
      color: "green"
    },
    partial: {
      label: "Partial",
      color: "orange"
    },
    "not-implemented": {
      label: "Not Implemented",
      color: "gray"
    }
  };
  const renderCard = (platform, value) => {
    if (!value) return null;
    const {status, note} = typeof value === "string" ? {
      status: value
    } : value;
    const config = STATUS_CONFIG[status];
    if (!config) return null;
    const titleMap = {
      ios: "SwiftUI",
      android: "Jetpack Compose",
      web: "Web"
    };
    return <Card key={platform} title={titleMap[platform] || platform}>
          <StatusBadge status={config.color} label={config.label} />
          {note && <div style={{
      marginTop: '0.5rem',
      fontSize: '0.875rem',
      color: '#6b7280'
    }}>
              {note}
            </div>}
      </Card>;
  };
  if (statuses == null) {
    return null;
  }
  return <Columns cols="3">
      {Object.entries(statuses).map(([platform, value]) => renderCard(platform, value))}
    </Columns>;
};

export const ComposeJS = ({code, name, height}) => {
  const encodedCode = useMemo(() => {
    if (!code) return "";
    try {
      return btoa(code);
    } catch (e) {
      console.error("Failed to encode code", e);
      return "";
    }
  }, [code]);
  if (!encodedCode) {
    return null;
  }
  return <iframe src={`https://www.metabind.ai/embed?code=${encodedCode}&name=${name ?? 'Example'}`} loading="lazy" style={{
    width: "100%",
    height: height || '350px',
    border: "1px solid #e5e7eb",
    borderRadius: "var(--rounded-2xl,1rem)",
    overflow: "hidden"
  }} title="ComposeJS Preview" />;
};

```typescript theme={null}
LinearGradient(props?: {
    colors?: Color[];
    startPoint?: UnitPoint;
    endPoint?: UnitPoint;
}): Gradient;
```

<ParamField path="colors" type="Color[]" optional>
  An array of colors for the gradient. Colors transition evenly between them.
</ParamField>

<ParamField path="startPoint" type="UnitPoint" optional>
  The starting point of the gradient line. See [UnitPoint](/bindjs/types/UnitPoint). Defaults to `"top"`.
</ParamField>

<ParamField path="endPoint" type="UnitPoint" optional>
  The ending point of the gradient line. See [UnitPoint](/bindjs/types/UnitPoint). Defaults to `"bottom"`.
</ParamField>

## Support

<PlatformStatuses
  statuses={{
ios: { status: "supported" },
android: { status: "supported" },
web: { status: "supported" },
}}
/>

## Usage

### As a standalone view

```typescript theme={null}
LinearGradient({
    colors: [Color("blue"), Color("purple")]
})
.frame({ height: 200 })
```

### Top-to-bottom gradient

```typescript theme={null}
LinearGradient({
    colors: [Color("red"), Color("orange"), Color("yellow")]
})
```

### Diagonal gradient

```typescript theme={null}
LinearGradient({
    colors: [Color("blue"), Color("purple")],
    startPoint: "topLeading",
    endPoint: "bottomTrailing"
})
```

### Horizontal gradient

```typescript theme={null}
LinearGradient({
    colors: [Color("green"), Color("blue")],
    startPoint: "leading",
    endPoint: "trailing"
})
```

### As a fill

```typescript theme={null}
RoundedRectangle({ cornerRadius: 16 })
    .fill(LinearGradient({
        colors: [Color("blue"), Color("purple")],
        startPoint: "leading",
        endPoint: "trailing"
    }))
    .frame({ height: 56 })
```

### As a foreground style

```typescript theme={null}
Text("Gradient Text")
    .font("largeTitle")
    .foregroundStyle(LinearGradient({
        colors: [Color("red"), Color("orange")],
        startPoint: "leading",
        endPoint: "trailing"
    }))
```

### As a background

```typescript theme={null}
VStack([
    Text("Content").foregroundStyle(Color("white"))
])
.padding(24)
.background(LinearGradient({
    colors: [Color("indigo"), Color("purple")],
    startPoint: "top",
    endPoint: "bottom"
}))
.cornerRadius(16)
```

## See Also

* [Color](/bindjs/styles/Color) -- solid color values
* [AngularGradient](/bindjs/styles/AngularGradient) -- sweep gradient around a center
* [RadialGradient](/bindjs/styles/RadialGradient) -- circular gradient from a center
* [UnitPoint](/bindjs/types/UnitPoint) -- coordinate system for gradient points
