Introducing Remotion Hub Pro - 50+ blocks and templates to build beautiful landing pages in minutes.


Docs
Linear Gradient

Linear Gradient

A linear gradient that can be used as a background for a component.

Linear Gradient

Installation

Copy and paste the following code into your project.

components/magicui/linear-gradient.tsx
import { CSSProperties } from "react";
 
type Direction =
  | "top"
  | "bottom"
  | "left"
  | "right"
  | "top left"
  | "top right"
  | "bottom left"
  | "bottom right";
 
interface LinearGradientProps {
  /**
   * The color to transition from
   * @default #00000000
   * @type string
   * */
  from?: string;
 
  /**
   * The color to transition to
   * @default #290A5C
   * @type string
   * */
  to?: string;
 
  /**
   * The width of the gradient
   * @default 100%
   * @type string
   * */
  width?: string;
 
  /**
   * The height of the gradient
   * @default 100%
   * @type string
   * */
  height?: string;
 
  /**
   * The direction of the gradient
   * @default bottom
   * @type string
   * */
  direction?: Direction;
 
  /**
   * The point at which the transition occurs
   * @default 50%
   * @type string
   * */
  transitionPoint?: string;
 
  /**
   * The class name to apply to the gradient
   * @default ""
   * @type string
   * */
  className?: string;
}
 
const LinearGradient = ({
  from = "#00000000",
  to = "rgba(120,119,198,0.3)",
  width = "100%",
  height = "100%",
  transitionPoint = "50%",
  direction = "bottom",
  className,
}: LinearGradientProps) => {
  const styles: CSSProperties = {
    position: "absolute",
    pointerEvents: "none",
    inset: 0,
    width: width,
    height: height,
    background: `linear-gradient(to ${direction}, ${from}, ${transitionPoint}, ${to})`,
  };
  return <div className={className} style={styles} />;
};
 
export default LinearGradient;

Props

Linear Gradient

PropTypeDescriptionDefault
fromstringThe starting color of the gradient#00000000
tostringThe ending color of the gradientrgba(120,119,198,0.3)
widthstringThe width of the gradient100%
heightstringThe height of the gradient100%
transitionPointstringThe point at which the gradient transitions from the starting color to the ending color50%
directionstringThe direction of the gradientbottom
classNamestringThe class name of the component""