
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
react-ratio
Advanced tools
Small component that allows you to create responsive elements that will keep their ratio on different screen sizes.
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.
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>
);
}
}
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
.
FAQs
Small component that allows you to create responsive elements that will keep their ratio on different screen sizes.
We found that react-ratio demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.