# Gradient

> Atom — orn-ui

> ⚠️ Requires <UIProvider>: This component (like every orn-ui component) must render inside a <UIProvider> ancestor, or it throws at runtime. See https://orn-ui-docs.vercel.app/getting-started.md

> Runs on Expo SDK 54, 55, 56 and 57, and on bare React Native >=0.81 with react >=19.1. No native modules — works in Expo Go, no prebuild.

## Installation

Install just this component (copies the source into your project, no npm dependency)
```bash
npx orn-ui add gradient
```

Or install the whole package and import it
```tsx
pnpm add orn-ui
import { Gradient } from 'orn-ui/gradient';
```

Depends on: core (theme + icons)

## Variants

### direction: vertical / horizontal

```tsx
<View style={{ width: '100%', gap: 12 }}>
  <Gradient colors={['#004cef', '#00cae1']} style={BOX} />
  <Gradient colors={['#004cef', '#00cae1']} direction="horizontal" style={BOX} />
</View>
```

### direction: diagonal / diagonal-reverse

```tsx
<VariantRow>
  <Gradient colors={['#7b2ff7', '#f107a3']} direction="diagonal" style={TILE} />
  <Gradient colors={['#7b2ff7', '#f107a3']} direction="diagonal-reverse" style={TILE} />
</VariantRow>
```

### several stops — one segment per pair of colors

```tsx
<Gradient colors={['#0f9b0f', '#00cae1', '#004cef', '#7b2ff7']} direction="horizontal" style={BOX} />
```

### steps: 3 (visible banding) vs 24 (default)

```tsx
<View style={{ width: '100%', gap: 12 }}>
  <Gradient colors={['#101014', '#00cae1']} steps={3} style={BOX} />
  <Gradient colors={['#101014', '#00cae1']} style={BOX} />
</View>
```

### children stay tappable — the gradient never takes the touch

```tsx
<Gradient
  colors={['#004cef', '#00cae1']}
  direction="diagonal"
  style={{ ...BOX, alignItems: 'center', justifyContent: 'center', gap: 8 }}
>
  <Body style={{ color: colors.white }}>Content sits on top</Body>
  <Button title="Press me" variant="secondary" onPress={() => {}} />
</Gradient>
```

## Full demo source

```tsx
const variants: VariantDef[] = [
  {
    label: 'direction: vertical / horizontal',
    content: (
      <View style={{ width: '100%', gap: 12 }}>
        <Gradient colors={['#004cef', '#00cae1']} style={BOX} />
        <Gradient colors={['#004cef', '#00cae1']} direction="horizontal" style={BOX} />
      </View>
    ),
  },
  {
    label: 'direction: diagonal / diagonal-reverse',
    content: (
      <VariantRow>
        <Gradient colors={['#7b2ff7', '#f107a3']} direction="diagonal" style={TILE} />
        <Gradient colors={['#7b2ff7', '#f107a3']} direction="diagonal-reverse" style={TILE} />
      </VariantRow>
    ),
  },
  {
    label: 'several stops — one segment per pair of colors',
    content: <Gradient colors={['#0f9b0f', '#00cae1', '#004cef', '#7b2ff7']} direction="horizontal" style={BOX} />,
  },
  {
    label: 'steps: 3 (visible banding) vs 24 (default)',
    content: (
      <View style={{ width: '100%', gap: 12 }}>
        <Gradient colors={['#101014', '#00cae1']} steps={3} style={BOX} />
        <Gradient colors={['#101014', '#00cae1']} style={BOX} />
      </View>
    ),
  },
  {
    label: 'children stay tappable — the gradient never takes the touch',
    content: (
      <Gradient
        colors={['#004cef', '#00cae1']}
        direction="diagonal"
        style={{ ...BOX, alignItems: 'center', justifyContent: 'center', gap: 8 }}
      >
        <Body style={{ color: colors.white }}>Content sits on top</Body>
        <Button title="Press me" variant="secondary" onPress={() => {}} />
      </Gradient>
    ),
  },
];
```

## Props

| Name | Type | Default | Description |
|---|---|---|---|
| `colors` | `string[]` | — | Gradient stops. One alone paints flat; none paints nothing. |
| `direction?` | `'vertical' \| 'horizontal' \| 'diagonal' \| 'diagonal-reverse'` | vertical | 'vertical' runs top to bottom, 'horizontal' left to right, 'diagonal' top-left to bottom-right and 'diagonal-reverse' top-right to bottom-left. |
| `steps?` | `number` | 24 | Bands per segment (a segment = a pair of consecutive colours). More bands = smoother transition and more views in the tree. |
| `children?` | `ReactNode` | — | Content drawn above the gradient. |
| `style?` | `StyleProp<ViewStyle>` | — | — |
