React Browser "container" components library , with tabs functionality.
import { BrowserContainer } from "react-browser-containers";
import { useState } from "react";
const App = () => {
const [tab, setTab] = useState(0);
return (
<ChromeBrowser
tab={tab}
setTab={setTab}
tabs={{
name: "Tab 1",
link: "/tab1",
content: <div>Tab 1 Content</div>,
}}
></ChromeBrowser>
);
};
export type ChromeBrowserProps = {
theme?: "light" | "dark"; // theme of the browser, default is light
tabs?: Array<{ // pages in the browser
name: string;
link: string; // decorative link in the URL bar
content: React.ReactNode; // content of the page
}>;
shadow?: boolean; // shadow of the browser, default is true
usecontentsize?: boolean; // default is false: browser will be the size of it's parent element. true: browser will be the size of it's content
leftIcons?: React.ReactNode; // leave empty for default icons
rightIcons?: React.ReactNode; // leave empty for default icons
children?: React.ReactNode; // content displayed under all pages
tab?: number;
setTab?: (tab: number) => void;
};
To run the project locally, follow the steps below:
- Clone the project:
git clone https://github.com/EnhancedJax/react-browser-containers.git
- Go to the project directory:
cd react-browser-containers
- Install dependencies:
npm install
- To start storybook:
npm run storybook
- To build the library:
npm run build
- To test the library:
npm run test
- Build the library:
npm run build
- Link the library:
npm link
- Ensure same react version:
npm link "../your-project/node_modules/react"
- Import and develop