Wondering what’s next for npm?Check out our public roadmap! »

react-full-height

1.2.2 • Public • Published

CircleCI Issues npm npm MIT License




Logo

Responsive component helping you make perfect full viewport height sections

View Demo · Report Bug · Request Feature


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 name Type Required Description
className string false The class name provided to the component. It takes CSS modules as well.
startWidth number false RWD Breakpoint representing (min-width) - By setting it you're telling component from which resolution it should be full-height section.
endWidth number false RWD Breakpoint representing (max-width) - Decide at which screen resolution your section should no longer be a full-heigh.
canExceed boolean false By 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

Install

npm i react-full-height

DownloadsWeekly Downloads

52

Version

1.2.2

License

MIT

Unpacked Size

62.1 kB

Total Files

13

Last publish

Collaborators

  • avatar