GithubHelp home page GithubHelp logo

codewithsundeep / fast-css Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5 KB

FastCSS is a simple and lightweight NPM package that allows you to dynamically generate and manage CSS styles in your web applications.

JavaScript 100.00%

fast-css's Introduction

FastCss-js NPM Package

Note: This is a beta version of FastCSS, and it will continue to receive updates and improvements. Please stay tuned for the latest features and enhancements.

FastCSS is a simple and lightweight NPM package that allows you to dynamically generate and manage CSS styles in your web applications. It provides functions for writing CSS styles to the <head> of your HTML document and updating existing styles. With FastCSS, you can easily generate CSS styles from JavaScript objects and apply them to your web pages.

Installation

You can install FastCSS using npm

npm install fastcss-js        

Usage

To use FastCSS in your project, you can import it as follows:

import fastCss from 'fastcss-js';

write(selector, styles)

This function allows you to write or update CSS styles for a specific selector. It takes a selector (string) and a styles object as arguments. If the selector already exists, it will update the existing styles; otherwise, it will create a new entry.

fastCss.write('.my-element', {
  backgroundColor: 'blue',
  fontSize: '16px',
}); 

init()

The init function initializes the FastCSS library by combining all the CSS styles previously written using the write function into a single CSS file and adding it to the <head> of your HTML document.

fastCss.init();

Example

Here's an example of how you can use FastCSS in your project:

import fastCss from 'fastcss-js';

// Write CSS styles for a selector
fastCss.write('.my-element1', {
  backgroundColor: 'blue',
  fontSize: '16px',
});
fastCss.write('.my-element2', {
  'box-shadow': 'rgba(0,0,0,0.5)',
fontSize: '16px',
});

fastCss.init();

React Example

import {useEffect} from 'react'
import fastCss from 'fastcss-js'
export default function Home(){
useEffect(()=>{
    fastCss.write('.my-element1', {
  backgroundColor: 'blue',
  fontSize: '16px',
});
fastCss.init()
  },[])
  return(
    <>
    <div className='my-element1'> This div background is blue</div>
    </>
  )
}

fast-css's People

Contributors

codewithsundeep avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.