Icon
RSC
Icons provide clear, intuitive visual cues for better usability and accessibility in digital products.
Installation
API Reference
Important Note
This is the documentation for gluestack-ui v2 (beta). For @gluestack-ui/themed (stable) documentation, refer to gluestack-ui v1.
This is an illustration of Icon component.
size
<Icon as={EditIcon} size="md" />
Installation
CLI
Manual
Run the following command:
npx gluestack-ui add icon
Step 1: Install the following dependencies:
npm i @gluestack-ui/icon
Step 2: Copy and paste the following code into your project.
"use client"import React, { useMemo } from "react"import { createIcon } from "@gluestack-ui/icon"import { Path, Svg } from "react-native-svg"import { tva } from "@gluestack-ui/nativewind-utils/tva"import { cssInterop } from "nativewind"import { VariantProps } from "@gluestack-ui/nativewind-utils"type IPrimitiveIcon = {height?: number | stringwidth?: number | stringfill?: stringcolor?: stringsize?: number | stringstroke?: stringas?: React.ElementTypeclassName?: stringclassNameColor?: string}const PrimitiveIcon = React.forwardRef<React.ElementRef<typeof Svg>,IPrimitiveIcon>(({height,width,fill,color,classNameColor,size,stroke,as: AsComp,...props},ref) => {color = color ?? classNameColorconst sizeProps = useMemo(() => {if (size) return { size }if (height && width) return { height, width }if (height) return { height }if (width) return { width }return {}}, [size, height, width])let colorProps = {}if (fill) {colorProps = { ...colorProps, fill: fill }}if (stroke !== "currentColor") {colorProps = { ...colorProps, stroke: stroke }} else if (stroke === "currentColor" && color !== undefined) {colorProps = { ...colorProps, stroke: color }}if (AsComp) {return <AsComp ref={ref} {...props} {...sizeProps} {...colorProps} />}return (<Svg ref={ref} height={height} width={width} {...colorProps} {...props} />)})export const UIIcon = createIcon({Root: PrimitiveIcon,})const iconStyle = tva({base: "text-typography-950 fill-none pointer-events-none",variants: {size: {"2xs": "h-3 w-3",xs: "h-3.5 w-3.5",sm: "h-4 w-4",md: "h-[18px] w-[18px]",lg: "h-5 w-5",xl: "h-6 w-6",},},})// @ts-expect-errorcssInterop(UIIcon, {className: {target: "style",nativeStyleToProp: {height: true,width: true,fill: true,color: "classNameColor",stroke: true,},},})type IIConProps = IPrimitiveIcon &VariantProps<typeof iconStyle> &React.ComponentPropsWithoutRef<typeof UIIcon>export const Icon = React.forwardRef<React.ElementRef<typeof Svg>, IIConProps>(({ size = "md", className, ...props }, ref) => {if (typeof size === "number") {return (<UIIconref={ref}{...props}className={iconStyle({ class: className })}size={size}/>)} else if ((props.height !== undefined || props.width !== undefined) &&size === undefined) {return (<UIIconref={ref}{...props}className={iconStyle({ class: className })}/>)}return (<UIIconref={ref}{...props}className={iconStyle({ size, class: className })}/>)})type ParameterTypes = Omit<Parameters<typeof createIcon>[0], "Root">const createIconUI = ({ ...props }: ParameterTypes) => {const UIIconCreateIcon = createIcon({ Root: Svg, ...props })return React.forwardRef<React.ElementRef<typeof Svg>>(({className,size,...props}: VariantProps<typeof iconStyle> &React.ComponentPropsWithoutRef<typeof UIIconCreateIcon>,ref) => {return (<UIIconCreateIcon// @ts-ignoreref={ref}{...props}className={iconStyle({ size, class: className })}/>)})}export { createIconUI as createIcon }// All Iconsconst AddIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M12 5V19"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M5 12H19"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})AddIcon.displayName = "AddIcon"export { AddIcon }const AlertCircleIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M12 8V12"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M12 16H12.01"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})AlertCircleIcon.displayName = "AlertCircleIcon"export { AlertCircleIcon }const ArrowUpIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M12 19V5"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M5 12L12 5L19 12"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const ArrowDownIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M12 5V19"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M19 12L12 19L5 12"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const ArrowRightIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M5 12H19"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M12 5L19 12L12 19"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const ArrowLeftIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M19 12H5"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M12 19L5 12L12 5"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})ArrowUpIcon.displayName = "ArrowUpIcon"ArrowDownIcon.displayName = "ArrowDownIcon"ArrowRightIcon.displayName = "ArrowRightIcon"ArrowLeftIcon.displayName = "ArrowLeftIcon"export { ArrowUpIcon, ArrowDownIcon, ArrowRightIcon, ArrowLeftIcon }const AtSignIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><><Pathd="M12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16Z"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M16 7.99999V13C16 13.7956 16.3161 14.5587 16.8787 15.1213C17.4413 15.6839 18.2044 16 19 16C19.7957 16 20.5587 15.6839 21.1213 15.1213C21.6839 14.5587 22 13.7956 22 13V12C21.9999 9.74302 21.2362 7.55247 19.8333 5.78452C18.4303 4.01658 16.4706 2.77521 14.2726 2.26229C12.0747 1.74936 9.76794 1.99503 7.72736 2.95936C5.68677 3.92368 4.03241 5.54995 3.03327 7.57371C2.03413 9.59748 1.74898 11.8997 2.22418 14.1061C2.69938 16.3125 3.90699 18.2932 5.65064 19.7263C7.39429 21.1593 9.57144 21.9603 11.8281 21.9991C14.0847 22.0379 16.2881 21.3122 18.08 19.94"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></></>),})AtSignIcon.displayName = "AtSignIcon"export { AtSignIcon }const BellIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M18 8C18 6.4087 17.3679 4.88258 16.2426 3.75736C15.1174 2.63214 13.5913 2 12 2C10.4087 2 8.88258 2.63214 7.75736 3.75736C6.63214 4.88258 6 6.4087 6 8C6 15 3 17 3 17H21C21 17 18 15 18 8Z"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M13.73 21C13.5542 21.3031 13.3018 21.5547 12.9982 21.7295C12.6946 21.9044 12.3504 21.9965 12 21.9965C11.6496 21.9965 11.3054 21.9044 11.0018 21.7295C10.6982 21.5547 10.4458 21.3031 10.27 21"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})BellIcon.displayName = "BellIcon"export { BellIcon }const CalendarDaysIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M19 4H5C3.89543 4 3 4.89543 3 6V20C3 21.1046 3.89543 22 5 22H19C20.1046 22 21 21.1046 21 20V6C21 4.89543 20.1046 4 19 4Z"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M16 2V6"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M8 2V6"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M3 10H21"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M8 14H8.01"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M12 14H12.01"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M16 14H16.01"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M8 18H8.01"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M12 18H12.01"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M16 18H16.01"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})CalendarDaysIcon.displayName = "CalendarDaysIcon"export { CalendarDaysIcon }const CheckIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M20 6L9 17L4 12"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const CheckCircleIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M12 22C17.523 22 22 17.523 22 12C22 6.477 17.523 2 12 2C6.477 2 2 6.477 2 12C2 17.523 6.477 22 12 22Z"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M9 12L11 14L15 10"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})CheckIcon.displayName = "CheckIcon"CheckCircleIcon.displayName = "CheckCircleIcon"export { CheckIcon, CheckCircleIcon }const ChevronUpIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",d: "M12 10L8 6L4 10",path: (<><Pathd="M18 15L12 9L6 15"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const ChevronDownIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M6 9L12 15L18 9"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const ChevronLeftIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M15 18L9 12L15 6"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const ChevronRightIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M9 18L15 12L9 6"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const ChevronsLeftIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M11 17L6 12L11 7"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M18 17L13 12L18 7"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const ChevronsRightIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M13 17L18 12L13 7"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M6 17L11 12L6 7"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const ChevronsUpDownIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M7 15L12 20L17 15"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M7 9L12 4L17 9"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})ChevronUpIcon.displayName = "ChevronUpIcon"ChevronDownIcon.displayName = "ChevronDownIcon"ChevronLeftIcon.displayName = "ChevronLeftIcon"ChevronRightIcon.displayName = "ChevronRightIcon"ChevronsLeftIcon.displayName = "ChevronsLeftIcon"ChevronsRightIcon.displayName = "ChevronsRightIcon"ChevronsUpDownIcon.displayName = "ChevronsUpDownIcon"export {ChevronUpIcon,ChevronDownIcon,ChevronLeftIcon,ChevronRightIcon,ChevronsLeftIcon,ChevronsRightIcon,ChevronsUpDownIcon,}const CircleIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})CircleIcon.displayName = "CircleIcon"export { CircleIcon }const ClockIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M12 6V12L16 14"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})ClockIcon.displayName = "ClockIcon"export { ClockIcon }const CloseIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M18 6L6 18"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M6 6L18 18"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})const CloseCircleIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M15 9L9 15"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M9 9L15 15"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/></>),})CloseIcon.displayName = "CloseIcon"CloseCircleIcon.displayName = "CloseCircleIcon"export { CloseIcon, CloseCircleIcon }const CopyIcon = createIcon({Root: Svg,viewBox: "0 0 24 24",path: (<><Pathd="M20 9H11C9.89543 9 9 9.89543 9 11V20C9 21.1046 9.89543 22 11 22H20C21.1046 22 22 21.1046 22 20V11C22 9.89543 21.1046 9 20 9Z"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/><Pathd="M5 15H4C3.46957 15 2.96086 14.7893 2.58579 14.4142C2.21071 14.0391 2 13.5304 2 13V4C2 3.46957 2.21071 2.96086 2.58579 2.58579C2.96086 2.21071 3.46957 2 4 2H13C13.5304 2 14.0391 2.21071 14.4142 2.58579C14.7893 2.96086 15 3.46957 15 4V5"strokeWidth="2"strokeLinecap="round"strokeLinejoin="round"/>