Responsive component helping you make perfect full viewport height sections
View Demo
ยท
Report Bug
ยท
Request Feature
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.
With npm
npm install --save react-full-height
Or with yarn
yarn add react-full-height
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>;
<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>
);
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>
);
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>
);
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) |
Distributed under the MIT License. See LICENSE
for more information.