### Install Allotment Source: https://github.com/johnwalley/allotment/blob/main/README.md Install the Allotment package from npm. ```sh npm install allotment ``` -------------------------------- ### Start Local Development Server Source: https://github.com/johnwalley/allotment/blob/main/website/README.md Starts a local development server for the website. Changes are reflected live without server restarts. Opens the site in a browser. ```bash npm run start ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/johnwalley/allotment/blob/main/website/README.md Installs all necessary project dependencies using npm. Run this command in the project root. ```bash npm i ``` -------------------------------- ### Install React and ReactDOM Source: https://github.com/johnwalley/allotment/blob/main/README.md Ensure you have React and ReactDOM installed as peer dependencies for Allotment. ```sh npm install react react-dom ``` -------------------------------- ### Install Allotment Source: https://github.com/johnwalley/allotment/blob/main/website/docs/getting-started.md Commands to add the package to your project dependencies. ```sh # with npm npm install allotment # with yarn yarn add allotment ``` -------------------------------- ### Basic Allotment Implementation Source: https://github.com/johnwalley/allotment/blob/main/website/docs/getting-started.md A minimal example showing how to render two panes within an Allotment container. Ensure the library CSS is imported for correct styling. ```tsx import * as React from "react"; import ReactDOM from "react-dom"; import { Allotment } from "allotment"; import "allotment/dist/style.css"; function App() { return (
Pane 1
Pane 2
); } ReactDOM.render(, document.querySelector("#app")); ``` -------------------------------- ### Build Static Website Content Source: https://github.com/johnwalley/allotment/blob/main/website/README.md Generates the static content for the website, typically placed in the 'build' directory. This output can be hosted on any static hosting service. ```bash npm run build ``` -------------------------------- ### Allotment with Default Sizes Source: https://github.com/johnwalley/allotment/blob/main/README.md Set initial sizes for panes using the `defaultSizes` prop. Sizes will be scaled proportionally if their sum doesn't match the container size. ```jsx
``` -------------------------------- ### Basic Allotment Usage Source: https://github.com/johnwalley/allotment/blob/main/README.md Import and use the Allotment component with basic content panes. Remember to import the default styles. ```jsx import React from "react"; import { Allotment } from "allotment"; import "allotment/dist/style.css"; export const App = () => ( ); ``` -------------------------------- ### Configure Individual Panes Source: https://github.com/johnwalley/allotment/blob/main/website/docs/getting-started.md Use the Allotment.Pane component to define specific constraints like minimum size or snapping behavior for individual panes. ```tsx import * as React from "react"; import ReactDOM from "react-dom"; import { Allotment } from "allotment"; import "allotment/dist/style.css"; function App() { return (
Pane 1
Pane 2
); } ReactDOM.render(, document.querySelector("#app")); ``` -------------------------------- ### Allotment.Pane API Source: https://github.com/johnwalley/allotment/blob/main/website/docs/pane.md Overview of the Pane component API for the Allotment library. ```APIDOC ## Pane ### Description The Pane component is a structural element used within the Allotment layout system to define individual sections or panels. ``` -------------------------------- ### Import Allotment CSS Source: https://github.com/johnwalley/allotment/blob/main/website/docs/faq.md Import the Allotment CSS at the root of your application to ensure proper styling. This is necessary for the component to render correctly. ```jsx import "allotment/dist/style.css"; ``` -------------------------------- ### Allotment with Pane Component Source: https://github.com/johnwalley/allotment/blob/main/README.md Utilize Allotment.Pane for finer control over individual pane properties like minimum size and snap behavior. ```jsx ``` -------------------------------- ### Allotment Pane Props Source: https://github.com/johnwalley/allotment/blob/main/website/docs/pane.md Configuration options for individual panes within the Allotment component. ```APIDOC ## Allotment Pane Props This section details the properties that can be configured for each pane within the Allotment component. ### Props - **maxSize** (number) - Optional - Maximum size of this pane. Overrides `maxSize` set on parent component. - **minSize** (number) - Optional - Minimum size of this pane. Overrides `minSize` set on parent component. - **priority** (`HIGH` | `NORMAL` | `LOW`) - Optional - Default: `NORMAL` - The priority of the pane when the layout algorithm runs. Panes with higher priority will be resized first. Only used when `proportionalLayout` is false. - **preferredSize** (number | string) - Optional - Preferred size of this pane. Allotment will attempt to use this size when adding this pane (including on initial mount) as well as when a user double clicks a sash, or the `reset` method is called on the Allotment instance. The size can either be a number or a string. If it is a number it will be interpreted as a number of pixels. If it is a string it should end in either "px" or "%". ``` -------------------------------- ### Programmatic Control of Allotment Component Source: https://github.com/johnwalley/allotment/blob/main/README.md Use a React ref to access the Allotment component instance for manual reset and resize operations. Ensure the ref is correctly attached to the Allotment component. ```jsx const ref = React.useRef(ref); return (
); ``` -------------------------------- ### Allotment Component Props Source: https://github.com/johnwalley/allotment/blob/main/website/docs/allotment.md Configuration properties for the Allotment component to control layout, sizing, and event callbacks. ```APIDOC ## Allotment Component Props ### Description Configuration properties for the Allotment component to control layout, sizing, and event callbacks. ### Parameters - **defaultSizes** (number[]) - Optional - An array of initial sizes of the panes. If the sum of the sizes differs from the size of the container then the panes' sizes will be scaled proportionally. - **maxSize** (number) - Optional - Maximum size of any pane. Default: Infinity. - **minSize** (number) - Optional - Minimum size of any pane. Default: 30. - **proportionalLayout** (boolean) - Optional - Resize each view proportionally when resizing container. Default: true. - **separator** (boolean) - Optional - Whether to render a separator between panes. Default: true. - **snap** (boolean) - Optional - Enable snap to zero for all panes. Default: false. - **vertical** (boolean) - Optional - Direction to split. If true then the panes will be stacked vertically, otherwise they will be stacked horizontally. Default: false. - **onReset** (func) - Optional - Callback that is fired whenever the user double clicks a sash. - **onVisibleChange** (func) - Optional - Callback that is fired whenever the user changes the visibility of a pane by snapping. ``` -------------------------------- ### Pane Visibility Configuration Source: https://github.com/johnwalley/allotment/blob/main/website/docs/pane.md Defines the visibility property for panes within the Allotment component. ```APIDOC ## Pane Configuration ### Description Controls the visibility state of a pane within the Allotment layout. ### Parameters #### Properties - **visible** (boolean) - Required - Whether this pane should be visible. Default is true. ``` -------------------------------- ### Customize Default CSS Variables Source: https://github.com/johnwalley/allotment/blob/main/README.md Define custom CSS variables to alter the default styling of the Allotment component, such as border colors. ```css :root { --focus-border: #007fd4; --separator-border: #838383; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.