Step 1: Select the shape
Press T and click the shape you want to apply the gradient to. Gradients work on fill or stroke for any path, primitive, or text element.
Step 2: Switch fill to gradient
Open the Appearance panel. Switch the fill type from Solid Color to Linear Gradient or Radial Gradient. The shape immediately picks up a default two-stop gradient so you can see what you are editing.
Step 3: Position the gradient on canvas
Switch to the Edit tool (E) - the gradient axis appears on canvas as draggable handles: endpoints for a linear gradient, center/focus/radius for a radial one. Drag the handles to set direction and length. Hold Shift to snap the angle to 15-degree increments.
Step 4: Add and tune stops
On the Fill row of the Appearance panel, the gradient preview bar shows your stops. Click the bar to add a stop at that position (or use the Add Stop button), and edit each stop's position, opacity, and color in the stop list. Use 3+ stops for nuanced gradients (e.g. shadow + base + highlight), and Reverse Stops to flip the ramp. Spread mode (Pad, Repeat, Reflect) controls what happens beyond the gradient axis.
Step 5: Reuse the gradient
The Library panel's Gradients tab automatically collects every gradient in the document. Click one to apply it to the current selection, Alt+click to apply it to the stroke, or drag it onto any shape - so a shading scheme stays consistent across a large illustration.
Step 6: Apply to stroke
Select the Stroke row of the Appearance panel and switch its paint type to a gradient too - the same stop list, spread modes, and on-canvas handles apply. Useful for ribbon and tape effects.