Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-ratio

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-ratio

Small component that allows you to create responsive elements that will keep their ratio on different screen sizes.

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
522
decreased by-18.94%
Maintainers
1
Weekly downloads
 
Created
Source

React aspect ratio component

npm version npm downloads

Small component that allows you to create responsive elements that will keep their ratio on different screen sizes.

It uses standard CSS hack to achieve it. Please note that Ratio ads wrapper element which makes things easier in certain scenarios.

Demo

Usage

import React, { Component } from 'react';
import Ratio from 'react-ratio';

export default class Example extends Component {
  render() {
    return (
      <Ratio ratio={ 16 / 9 }>
        YOUR CONTENT GOES HERE
      </Ratio>
    );
  }
}

Props

  • ratio, default 1

    Aspect ratio value. E.g. for 16:9 ratio, pass 16 / 9.

    Zero will default it back to one.

  • className, default ''

    Wrapper element class name

  • ratioClassName, default ''

    Helper div class name.

  • contentClassName, default ''

    Content div class name

  • style, default {}

    Object with CSS styles for the wrapper element. By default it adds display: block but it can be overridden.

  • tagName, default 'div'

    HTML element to be used for the wrapper element. E.g. you can pass a or aside.

All other props will be pass to the wrapper element. This is useful for passing accessibility props like aria-label or tabIndex.

License

MIT

Keywords

FAQs

Package last updated on 01 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc