Skip to content

kimjh96/basic-styled

Repository files navigation

basic-styled

basic-styled 는 기본적인 스타일링 기능을 제공하는 CSS-in-JS 라이브러리예요. 고급 스타일링이나 성능이 중요하지 않은 간단한 프로젝트에 사용할 가벼운 라이브러리가 필요하시다면 사용해 보세요!

기능

  • 작은 사이즈
  • 간단한 사용
  • 의존성 없음
  • Theming 지원
  • Server-Side Rendering 지원
  • Server Comonent 지원

지원

시작

pnpm add basic-styled
import basic-styled from 'basic-styled';

function App() {
  return (
    <Box>App</Box>
  );
}

const Box = styled.div`
  border: 1px solid;
`;

예시

Theming

// App.tsx

import ThemeProvider from 'basic-styled/setup/ThemeProvider';

const theme = {
    palette: {
        primary: '#007bff',
    }
}

return (
  <ThemeProvider theme={theme}>
    <div>App</div>
  </ThemeProvider>
);
// with TypeScript

import "basic-styled";

declare module "basic-styled" {
    export interface BasicTheme {
        palette: {
            primary: string;
        };
    }
}

Next.js

// layout.tsx

import createBuilder from "basic-styled/setup/createBuilder";

const theme = {
    palette: {
        primary: '#007bff',
    }
}

createBuilder({
    prefix: 'basic-styled', // prefix for class name, default is 'basic-styled'
    theme
});

return (
    <html lang="ko">
        <body>
            {...}
        </body>
    </html>
);
// providers.tsx

'use client';

import ThemeProvider from 'basic-styled/setup/ThemeProvider';

const theme = {
    palette: {
        primary: '#007bff',
    }
}

return (
  <ThemeProvider theme={theme}>
    <div>App</div>
  </ThemeProvider>
);