rsnext/examples/image-component/pages/fill.tsx
Steven e2f16f96c2
Update next/image docs and examples (#41434)
This PR updates the docs for the following code change:

- #41399

There are a few updates here:

- [x] Update docs
- [x] Update links to docs inside component
- [x] Update examples
- [x] Fix corner cases in codemod
2022-10-17 10:41:35 -04:00

46 lines
1 KiB
TypeScript

import Image from 'next/image'
import ViewSource from '../components/view-source'
import mountains from '../public/mountains.jpg'
const Fill = () => (
<div>
<ViewSource pathname="pages/layout-fill.tsx" />
<h1>Image Component With Layout Fill</h1>
<div style={{ position: 'relative', width: '300px', height: '500px' }}>
<Image
alt="Mountains"
src={mountains}
fill
sizes="100vw"
style={{
objectFit: 'cover',
}}
/>
</div>
<div style={{ position: 'relative', width: '300px', height: '500px' }}>
<Image
alt="Mountains"
src={mountains}
fill
sizes="100vw"
style={{
objectFit: 'contain',
}}
/>
</div>
<div style={{ position: 'relative', width: '300px', height: '500px' }}>
<Image
alt="Mountains"
src={mountains}
quality={100}
fill
sizes="100vw"
style={{
objectFit: 'none',
}}
/>
</div>
</div>
)
export default Fill