Icon component nextjs react

agnusdei·2023년 8월 18일
0

'use client';

import React from 'react';
import Image from 'next/image';

export interface IconProps {
  name: string;
  className?: string;
}

const Icon: React.FC<IconProps> = ({ name, className = 'w-4 h-4' }) => {
  const src = encodeURI(`https://api.iconify.design/${name}.svg`);

  if (src) {
    return (
      <div className={'relative ' + className}>
        <Image
          fill
          src={src}
          alt={name}
          className={className}
          style={{
            backgroundColor: 'inherit',
          }}
        />
      </div>
    );
  }
};

export default Icon;

0개의 댓글