1.2.3 • Published 2 years ago

react-full-height v1.2.3

Weekly downloads
316
License
MIT
Repository
github
Last release
2 years ago

CircleCI Issues npm npm MIT License

Getting Started

This component has been built to help you create responsive and customizable full-height sections. You can always have a full-height section or you can adjust FullHeight component easily to achieve full-height effect only in mobile, desktop or in some specific resolution range.

Installation

With npm

npm install --save react-full-height

Or with yarn

yarn add react-full-height

Usage

Basic usage

The very basic usage is to just wrap your content in FullHeight.

import React from "react";
import FullHeight from "react-full-height";

const MySection = () => <FullHeight>My section content</FullHeight>;

Passing className and section default props

<FullHeight /> renders a section, and it will accept any usual div/section props, including className.

import React from "react";
import FullHeight from "react-full-height";

const MyCustomSection = () => (
  <FullHeight className="section-styles">
    <h2>My section title</h2>
    <p>Full-height section content</p>
  </FullHeight>
);

Follow the content height when it exceeds the viewport height

By default <FullHeight /> has a viewport height, so when your content inside will exceed this height, then the section will be scrollable. If you want the <FullHeight /> to follow the content section in this case, then add canExceed prop.

import React from "react";
import FullHeight from "react-full-height";

const MyCustomSection = () => (
  <FullHeight canExceed>
    <h2>My section title</h2>
    <p>A lot of content, that the height of the content exceeds viewport height....</p>
  </FullHeight>
);

Make your full-height section responsive

You can decide about breakpoint by your own

import React from "react";
import FullHeight from "react-full-height";

/*
 * Make full-height section only in the mobile resolution screens (up to 768px)
 */
const MobileFullHeightSection = () => (
  <FullHeight endWidth={768}>My mobile only full-height section</FullHeight>
);

/*
 * Make full-height section only in the desktop resolution screens (from 1024px)
 */
const DesktopFullHeightSection = () => (
  <FullHeight startWidth={1024}>My desktop only full-height section</FullHeight>
);

/*
 * Make full-height section only in the tablet resolution screens (from 768px to 1024px)
 */
const TabletFullHeightSection = () => (
  <FullHeight startWidth={768} endWidth={1024}>
    My tablet only full-height section
  </FullHeight>
);

This component takes following props

Prop nameTypeRequiredDescription
classNamestringfalseThe class name provided to the component. It takes CSS modules as well.
startWidthnumberfalseRWD Breakpoint representing (min-width) - By setting it you're telling component from which resolution it should be full-height section.
endWidthnumberfalseRWD Breakpoint representing (max-width) - Decide at which screen resolution your section should no longer be a full-heigh.
canExceedbooleanfalseBy default is false. When you set it as true and your section content will exceed viewport height then the section will follow the content height (by default (without this props) the section will be scrollable)

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Author: @qmixi

Demo: https://qmixi.github.io/react-full-height

Project Link: https://github.com/qmixi/react-full-height