1.4.0 • Published 7 months ago
@react-visual/next v1.4.0
@react-visual/next 
Renders images and videos into a container. Features:
- Uses
next/imageto render images - Easily render assets using aspect ratios
- Videos are lazyloaded (unless
priorityflag is set)
Install
yarn add @react-visual/nextImages will be rendered using next/image so expect to do configuration of remotePatterns for CMS hosted images.
Usage
import Visual from '@react-visual/next'
export default function Example() {
return (
<Visual
image='https://placehold.co/300x150'
video='https://placehold.co/300x150.mp4'
aspect={300/150}
sizes='100vw'
alt='Example using placeholder images' />
)
}For more examples, read the Cypress component tests.
Props
Sources
| Prop | Type | Description |
|---|---|---|
image | string | URL to an image asset. |
video | string | URL to a video asset asset. |
placeholderData | string | A Data URL that is rendered before the image loads via next/image's blurDataURL. |
Layout
| Prop | Type | Description |
|---|---|---|
expand | boolean | Make the Visual fill it's container via CSS using absolute positioning. |
aspect | number | Force the Visual to a specific aspect ratio. |
width | number, string | A CSS dimension value or a px number. |
height | number, string | A CSS dimension value or a px number. |
fit | string | An object-fit value that is applied to the assets. Defaults to cover. |
position | string | An object-position value. |
Loading
| Prop | Type | Description |
|---|---|---|
priority | boolean | Sets next/image's priority and videos to not lazy load. |
sizes | string | Sets next/image's sizes prop. |
imageLoader | Function | This is passed through to next/image's loader prop. |
Video
| Prop | Type | Description |
|---|---|---|
paused | boolean | Disables autoplay of videos. This prop is reactive, unlike the paused property of the html <video> tag. You can set it to true to pause a playing video or set it to false to play a paused video. |
Accessibility
| Prop | Type | Description |
|---|---|---|
alt | string | Sets the alt attribute or aria-label value, depending on asset type. |
Theming
| Prop | Type | Description |
|---|---|---|
className | string | Add a custom CSS class. |
style | CSSProperties | Add additional styles. |
1.4.0
7 months ago
1.3.1
11 months ago
1.3.0
1 year ago
1.2.0
1 year ago
1.1.0
1 year ago
1.0.0
1 year ago
0.8.1
2 years ago
0.8.0
2 years ago
0.7.1
2 years ago
0.7.0
2 years ago
0.6.0
2 years ago
0.5.1
2 years ago
0.5.0
2 years ago
0.4.1
2 years ago
0.4.0
2 years ago
0.3.4
2 years ago
0.3.3
2 years ago
0.3.2
2 years ago
0.3.1
2 years ago
0.3.0
2 years ago