🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

tailwindcss-unsplash

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tailwindcss-unsplash

[![Version][npm-version-shield]][npm] [![Downloads][npm-stats-shield]][npm] [![License][license-shield]][license]

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

Tailwind CSS Unsplash Background

Version Downloads License

Introduction

TailwindCSS / WindiCSS plugin to easily apply background from unsplash.com into your CSS.

Tailwind CSS:

<!-- Using dynamic images -->
<div class="bg-unsplash-[YMi66afAE3I]" />
<div class="bg-unsplash-[YMi66afAE3I/lg]" />
<div class="bg-unsplash-[YMi66afAE3I/1920]" />

<!-- Using static images --> 
<div class="bg-unsplash-yosemite" />
<div class="bg-unsplash-yosemite-lg" />
<div class="bg-unsplash-yosemite-[1920]" />

Windi CSS:

<!-- Dynamic with TailwindCSS -->
<div class="bg-unsplash-YMi66afAE3I" />
<div class="bg-unsplash-YMi66afAE3I-lg" />
<div class="bg-unsplash-YMi66afAE3I-1920" />

<!-- Image from theme --> 
<div class="bg-unsplash-yosemite" />
<div class="bg-unsplash-yosemite-lg" />
<div class="bg-unsplash-yosemite-1920" />

You can extract the ID like so:

  • https://unsplash.com/photos/2GjGnBizWuQ
  • https://images.unsplash.com/photo-1645036993886-efdfd96ca97f?ixlib=rb-1.2.1&fit=crop&w=735&q=80

When using the dynamic syntax, make sure you escape dashes:

  • ❌ : bg-unsplash-[1517411032315-54ef2cb783bb/64]
  • ✔️ : bg-unsplash-[1517411032315\-54ef2cb783bb/64]

Installation

npm install -D tailwindcss-unsplash
yarn add -D tailwindcss-unsplash
pnpm add -D tailwindcss-unsplash

Simple usage

{
  theme: {
    unsplashImages: {
      lyon: 'YMi66afAE3I',
      stars: '4dpAqfTbvKA',
      yosemite: 'zOXUvQ3Xo3s',
      gradient: 'LeG68PrXA6Y',
    },
    unsplashResolutions: {
      default: null, // --- Allows maximum available resolution by default.
      xs: 480,
      sm: 720,
      md: 1280,
      lg: 1920,
      xl: 3840,
      '2xl': 7680,
    },
  },
  plugins: [
    require('tailwindcss-unsplash'),
  ],
}

The plugin generates the following utilities:

.bg-unsplash-[image-key] {
  background-image: url(https://unsplash.com/photos/{image-id}/download;
}

.bg-unsplash-[image-key]-[resolution-key] {
  background-image: url(https://unsplash.com/photos/{image-id}/download?w={resolution};
}

FAQs

Package last updated on 18 Feb 2022

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