Flowbite + Remix
Remix는 React 기반의 풀스택 웹 프레임워크예요. 분산 시스템을 활용하고 네이티브 Web Fetch API로 서버에서 콘텐츠를 불러와 페이지 로드를 더 빠르게 해주는 게 특징이에요. 수십만 명의 개발자와 대기업에서 사용 중이며, Shopify가 2022년 10월 31일에 인수했어요.
출처: 문서
본문
이 가이드를 따라 새 Remix 프로젝트를 만들고, Flowbite의 UI 컴포넌트와 함께 Tailwind CSS를 설치·설정하는 법을 배워요.
요구사항 (Requirements)
시작 전에 로컬 머신에 Node.js와 NPM이 설치되어 있어야 Remix, Tailwind CSS, Flowbite 등 필요한 패키지를 설치할 수 있어요.
시작하기 (Getting started)
가장 빠른 방법은 프로젝트 생성 CLI를 쓰는 거예요. Flowbite React, Tailwind CSS, 모든 필수 설정이 갖춰진 새 Remix 프로젝트를 만들어줘요.
npx create-flowbite-react@latest -t remix
이 명령은 새 Remix 프로젝트를 만들고 Tailwind CSS(v4), Flowbite React와 모든 의존성을 설치하며, 다크 모드 지원과 시작용 예제 컴포넌트 몇 개를 설정해줘요.
기존 프로젝트에 추가 (Add to existing project)
이미 Remix 프로젝트가 있고 Flowbite React를 추가하고 싶다면 초기화 CLI를 사용해요.
npx flowbite-react@latest init
이 명령은 기존 Remix 프로젝트 안에서 Flowbite React와 의존성을 자동으로 설치하고, Tailwind에 Flowbite 플러그인을 구성해줘요.
수동 설치 (Custom installation)
직접 모든 것을 설정하거나 구성에 대한 더 많은 제어가 필요하다면 다음 단계를 따라요.
새 프로젝트 만들기 — 공식 CLI 도구로 새 Remix 프로젝트를 만들어요.
npx create-remix@latest
Flowbite React 설치 — 이어서 Flowbite React를 설치해요.
npx flowbite-react@latest init
이 명령은 Flowbite React를 설치하고 Tailwind와 Vite에 Flowbite 플러그인을 구성해요.
다크 모드 추가 — Remix 같은 서버 사이드 렌더링 앱에서는, Remix가 콘텐츠를 하이드레이션하기 전 페이지 깜빡임을 피하려면(다크 모드가 설정된 경우) <head> 태그 안에 ThemeModeScript 컴포넌트를 렌더링해야 해요. 이 컴포넌트는 하이드레이션 전에 <html> 요소에 dark를 추가하거나 제거하는 스크립트 태그를 렌더링해요.
app/root.tsx의 <head> 태그에서 ThemeModeScript를 가져와 렌더링해요.
import { ThemeModeScript } from 'flowbite-react';
export default function Layout() {
return (
<html lang="en">
<head>
{/* ... */}
<ThemeModeScript />
</head>
<body>{/* ... */}</body>
</html>
);
}
축하해요! 이제 Remix 프로젝트 안에서 Flowbite React를 설치·설정했어요.
Remix 컴포넌트 (Remix components)
Flowbite React를 설치했으니 라이브러리의 컴포넌트를 사용해보아요.
// app/routes/_index.tsx
import { Button } from 'flowbite-react';
export default function Index() {
return <Button>Click me</Button>;
}
컴포넌트와 사용법을 더 자세히 보려면 Flowbite React 문서를 확인해요.
테마 커스터마이징 (Theme customization)
Flowbite React는 새 테마 엔진을 사용한 고급 커스터마이징 시스템을 제공해요. 컴포넌트의 className 속성을 직접 사용해 스타일을 입힐 수도 있고, <ThemeProvider> 컴포넌트에 테마 객체를 넘겨서 스타일할 수도 있어요.
예를 들어 버튼 컴포넌트를 업데이트하는 간단한 방법이에요.
import { Button } from "flowbite-react";
function App() {
return <Button className="bg-red-500 hover:bg-red-600">Custom Button</Button>;
}
또한 createTheme 헬퍼로 테마 객체를 만들어 <ThemeProvider> 컴포넌트에 넘기면, 하위 컴포넌트까지 스타일할 수 있어요.
import { Button, createTheme, ThemeProvider } from "flowbite-react";
const customTheme = createTheme({
button: {
color: {
primary: "bg-red-500 hover:bg-red-600",
secondary: "bg-blue-500 hover:bg-blue-600",
},
size: {
lg: "px-6 py-3 text-lg",
},
},
});
function App() {
return (
<ThemeProvider theme={customTheme}>
<Button color="primary">Red Button</Button>
<Button color="secondary" size="lg">
Large Blue Button
</Button>
</ThemeProvider>
);
}
오픈소스 커뮤니티 (Open-source community)
Flowbite React UI 라이브러리는 MIT 라이선스 아래 무료로 제공되는 오픈소스 프로젝트예요. 소스 코드는 GitHub에 호스팅되어 있으며, 개발자 커뮤니티와 함께 협업하고 기여할 수 있어요.
개발 지원 (Support development)
오픈소스 활동을 지원하고 싶다면 Flowbite 프로 버전을 살펴보세요. 400개 이상의 컴포넌트와 템플릿, Figma 디자인 시스템, 관리 대시보드 등을 포함하고 있어요.