{"id":15663609,"url":"https://github.com/transitive-bullshit/react-block-image","last_synced_at":"2025-07-18T13:32:25.483Z","repository":{"id":30581457,"uuid":"125445888","full_name":"transitive-bullshit/react-block-image","owner":"transitive-bullshit","description":"React replacement for img with more control + fallback support.","archived":false,"fork":false,"pushed_at":"2023-01-25T10:44:55.000Z","size":1741,"stargazers_count":17,"open_issues_count":42,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-18T08:16:34.341Z","etag":null,"topics":["background-image","img","react","react-component"],"latest_commit_sha":null,"homepage":"https://transitive-bullshit.github.io/react-block-image/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/transitive-bullshit.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-16T01:15:42.000Z","updated_at":"2024-10-16T22:16:26.000Z","dependencies_parsed_at":"2023-02-14T06:40:13.906Z","dependency_job_id":null,"html_url":"https://github.com/transitive-bullshit/react-block-image","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/transitive-bullshit/react-block-image","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Freact-block-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Freact-block-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Freact-block-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Freact-block-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/transitive-bullshit","download_url":"https://codeload.github.com/transitive-bullshit/react-block-image/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Freact-block-image/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265768254,"owners_count":23825092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["background-image","img","react","react-component"],"created_at":"2024-10-03T13:38:53.450Z","updated_at":"2025-07-18T13:32:25.432Z","avatar_url":"https://github.com/transitive-bullshit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-block-image ([demo](https://transitive-bullshit.github.io/react-block-image/))\n\n\u003e React replacement for `img` that uses a `div` with `background-image` for more control + fallback support.\n\n[![NPM](https://img.shields.io/npm/v/react-block-image.svg)](https://www.npmjs.com/package/react-block-image) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Features\n\n- **background-image** for easier control over sizing\n- **Fallback** image support\n- **Loading** customization\n- Zero dependencies\n- Used in production at [Automagical](https://automagical.ai/)\n\n## Install\n\n```bash\nnpm install --save react-block-image\n# of\nyarn add react-block-image\n```\n\n## Usage\n\nCheck out the [demo](https://transitive-bullshit.github.io/react-block-image/) in the [example folder](https://github.com/transitive-bullshit/react-block-image/tree/master/example).\n\nMinimal:\n\n```jsx\nimport React, { Component } from 'react'\n\nimport BlockImage from 'react-block-image'\n\nclass Example extends Component {\n  render () {\n    return (\n      \u003cBlockImage src='https://example.com/example.jpg' /\u003e\n    )\n  }\n}\n```\n\nWith fallback image and loading animation:\n\n```jsx\nimport React, { Component } from 'react'\n\nimport BlockImage from 'react-block-image'\nimport placeholder from './placeholder.jpg'\n\nclass Example extends Component {\n  render () {\n    return (\n      \u003cBlockImage\n        src='https://example.com/example.jpg'\n        fallback={placeholder}\n        showPreview={true}\n        loader={\n          \u003cMyLoadingAnimation /\u003e\n        }\n      /\u003e\n    )\n  }\n}\n```\n\n## Props\n\n| Property      | Type               | Default                               | Description                                                                                                                                  |\n|:--------------|:-------------------|:--------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------|\n| `src`         | string           | undefined                           | Required URL of the preferred image source.                                                                                                  |\n| `fallback`    | string           | undefined                           | Optional URL of a fallback image.                                                                                                            |\n| `children`    | node             | undefined                           | Optional children.                                                                                                                           |\n| `showPreview` | boolean          | false                               | Whether or not to show fallback while preferred `src` is loading.                                                                            |\n| `loader`      | node             | undefined                           | Optional node to show while `src` is loading.                                                                                                |\n| `backgroundSize`        | string           | cover                     | Convenience prop for setting `background-size` on `style`.                                                                                   |\n| `backgroundPosition`    | string           | center center             | Convenience prop for setting `background-position` on `style`.                                                                               |\n| `backgroundRepeat`      | string           | no-repeat                 | Convenience prop for setting `background-repeat` on `style`.                                                                                 |\n| `style`                 | object           | undefined                 | Optional `style` overrides for root element.                                                                                                 |\n| `className`             | string           | undefined                 | Optional `className` override for root element.                                                                                              |\n| `...`                   | ...              | undefined                 | All other props are applied to the root element.                                                                                             |\n\n## License\n\nMIT © [transitive-bullshit](https://github.com/transitive-bullshit)\n\nThis module was bootstrapped with [create-react-library](https://github.com/transitive-bullshit/create-react-library).\n\nSupport my OSS work by \u003ca href=\"https://twitter.com/transitive_bs\"\u003efollowing me on twitter \u003cimg src=\"https://storage.googleapis.com/saasify-assets/twitter-logo.svg\" alt=\"twitter\" height=\"24px\" align=\"center\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransitive-bullshit%2Freact-block-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftransitive-bullshit%2Freact-block-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransitive-bullshit%2Freact-block-image/lists"}