Welcome to Rothko-UI, a comprehensive UI component library designed with flexibility and ease of use in mind. This monorepo contains various packages, with @rothko-ui/ui
and @rothko-ui/icons
being the primary ones for external use.
@rothko-ui/ui
: The main package containing all the UI components.@rothko-ui/icons
: A collection of SVG icons optimized for Rothko-UI.
Before using any Rothko-UI components, it's essential to wrap your application or component tree with the RothkoProvider
. This context provider ensures that all components function correctly and inherit the necessary themes and configurations.
import { RothkoProvider } from '@rothko-ui/ui';
function MyApp() {
return <RothkoProvider>{/* Your application components here */}</RothkoProvider>;
}
After setting up the RothkoProvider
, you can import and use the components:
import { Button } from '@rothko-ui/ui';
function MyComponent() {
return <Button>Click Me</Button>;
}
The @rothko-ui/icons
package provides a range of SVG icons:
import { HeartIcon } from '@rothko-ui/icons';
function MyComponent() {
return <HeartIcon />;
}
To get started with Rothko-UI:
npm install @rothko-ui/ui @rothko-ui/icons
or
yarn add @rothko-ui/ui @rothko-ui/icons
Rothko UI utilizes styled-components
for styling its components. If you're integrating Rothko UI into a server-side rendered (SSR) application, it's essential to ensure that the style sheets are correctly generated and sent to the client. This prevents flash-of-unstyled-content (FOUC) issues and ensures a smooth user experience.
Next.js is a popular React framework that supports SSR out of the box. If you're using Rothko UI with Next.js, special considerations need to be made for styled-components
.
To correctly handle styled-components
with SSR in Next.js:
-
Install Required Dependencies: Ensure you have both
styled-components
and its Babel plugin installed:yarn add styled-components babel-plugin-styled-components
-
Configure Babel: Update your
.babelrc
(orbabel.config.json
) to include thestyled-components
plugin:{ "presets": ["next/babel"], "plugins": [["styled-components", { "ssr": true }]] }
-
Use
ServerStyleSheet
: In your custom_document.js
(or_document.tsx
), useServerStyleSheet
fromstyled-components
to collect and inline the styles:import Document from 'next/document'; import { ServerStyleSheet } from 'styled-components'; export default class MyDocument extends Document { static async getInitialProps(ctx) { const sheet = new ServerStyleSheet(); const originalRenderPage = ctx.renderPage; try { ctx.renderPage = () => originalRenderPage({ enhanceApp: App => props => sheet.collectStyles(<App {...props} />), }); const initialProps = await Document.getInitialProps(ctx); return { ...initialProps, styles: ( <> {initialProps.styles} {sheet.getStyleElement()} </> ), }; } finally { sheet.seal(); } } }
By following these steps, styled-components
will correctly generate and inline styles during server-side rendering, ensuring that your Rothko UI components are styled appropriately when your Next.js application is loaded.
@luxo-ai [email protected]
Support the project: 0x7A67fF6354d983B6cfc3a7f7C5BA93f73C864b32
MIT