My React project is unable to import the foundation SCSS file into the App.scss file

After installing zurb-foundation using npm, I attempted to import the .scss file into my App.scss file. Utilizing the "live sass server" for compiling the .scss code into .css code, a .css file was generated but did not display any code despite successfully importing the .scss from foundation into my App.scss

The image shows the .scss code on the left and the corresponding .css code on the right

Answer №1

if you happen to have three different files:

SASS FORMAT

The first file looks like this:

SASS SYNTAX
// foundation/_code.sass
code
  padding: .25em
  line-height: 0

The second file is as follows:

// foundation/_lists.sass
ul, ol
  text-align: left

  & &
    padding:
      bottom: 0
      left: 0

You are able to combine your files using imports in the following manner.

Please note: The file name must adhere to this specific syntax:

_{name of file}.sass

// app.sass
@import foundation/code, foundation/lists

SCSS STYLE

The first file appears like this:

// foundation/_code.scss
code {
  padding: .25em;
  line-height: 0;
}

And the second file has the structure below:

// foundation/_lists.scss
ul, ol {
  text-align: left;

  & & {
    padding: {
      bottom: 0;
      left: 0;
    }
  }
}

Lastly, there is a third file included:

// style.scss
@import 'foundation/code', 'foundation/lists';

To delve deeper into this topic, check out: sass docs @import

Answer №2

Did you explore the option of using

@import '../node_modules/foundation-sites/scss/foundation.scss'
?

Instead of importing the entire Foundation code, consider selecting only what you need, such as the breakpoint mixins for your SCSS:

@import "~foundation-sites/scss/util/util";
@import "~foundation-sites/scss/util/breakpoint";

By selectively importing components, you can minimize the size of your CSS file and optimize performance.

For more information, check out

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Youtube Subscribe Embed feature is causing my image to lose its corners

When I use the official embed code from Google Developers to embed my YouTube channel, it cuts off the corners of my image and leaves white corners. This doesn't look good on my website with a black background. <script src="https://apis.google ...

What is the best way to incorporate CSS from node_modules into Vite for production?

I have a TypeScript web application where I need to include CSS files from NPM dependencies in index.html. Here is an example of how it is done: <link rel="stylesheet" type="text/css" href="./node_modules/notyf/notyf.min.css&quo ...

What causes the variation in output results between axios and express when using dot notation?

A geo tool application is in the works, built with reactjs. The concept involves users submitting a city name which then triggers a post request. This request searches through a city list.JSON file to find the corresponding city and returns its geolocation ...

When the Fetch response displays a 401 Unauthenticated error, it typically indicates an issue with authentication in a React frontend

For a university assignment, I developed a Spring Boot backend that requires authorization/authentication. The API functions correctly when tested standalone through Postman requests with the correct authentication/authorization. However, when attempting t ...

"Seamless responsiveness in design with jQuery, but encountering compatibility issues

My usage of jQuery is quite basic to ensure that elements are properly positioned when they are moved: function ipad() { var width = jQuery(window).width(); if (width < 1200 && width >= 768){ //if tablet jQuery('.mobbut').css(&apo ...

What are the solutions for resolving 'undefined' errors while working with TypeScript Interfaces?

When working with TypeScript in my Next.js project, I encountered the following error message: Type '{ banner: { id: number; bannerImageUrl: string; } | undefined; }' is not assignable to type 'IntrinsicAttributes & Banner'. Prope ...

Maintain the layout of HTML page while reducing the window size

My webpage is experiencing an issue. When I resize the window, the placement of all elements becomes misaligned and the layout gets distorted. ...

When using React createPortal, the element is not inserted into the DOM without any issues

In my quest to develop a dynamic modal using React and MaterialUI, I am currently implementing them this way: // Confirm.js import { WarningAmber } from '@mui/icons-material' import { LoadingButton } from '@mui/lab' import { Button, Dia ...

Instead of using setTimeout in useEffect to wait for props, opt for an alternative

Looking for a more efficient alternative to using setTimeout in conjunction with props and the useEffect() hook. Currently, the code is functional: const sessionCookie = getCookie('_session'); const { verifiedEmail } = props.credentials; const [l ...

Is it possible to iterate through div elements using .each while incorporating .append within an AJAX call?

After sending AJAX requests and receiving HTML with multiple div elements (.card), I am using .append to add new .card elements after each request, creating an infinite scroll effect. However, I am facing issues when trying to use .each to iterate over all ...

Leveraging a returned value from a function in Typescript within a React component

I am currently facing a challenge where I need to extract values from a Typescript function and use them to dynamically render a React page. Specifically, the two values I am working with are the outputs of getIcon() and getSpaces(). This is how I attempt ...

Error encountered in MDAVSCLI: EPERM, operation not allowed on 'C:WindowsCSCv2.0.6'

After successfully installing VS tools for Cordova on VS2013 with all default settings, I encountered a node error while attempting to build and run the default "BlankCordovaApp" template. 1>MDAVSCLI : error : EPERM, operation not permitted 'C:&b ...

How to extract just the year from Material-UI's date picker in React

const displayYearOnly = (date) => { const year = date.getFullYear(); console.log(year); }; return ( <div style={{ marginRight: "20px" }}> <LocalizationProvider dateAdapter={AdapterDayjs}> <DemoContainer componen ...

Whenever a new entry is made into the textfield, the onChange feature triggers a reset on the content within the textfield

I'm experiencing an issue while creating a SignUp authentication page with Firebase. Every time I try to input text in the text field, it gets reset automatically. I have been unable to identify the root cause of this problem. It seems to be related t ...

Retrieve the id for the chosen user name within a function that contains an array of objects

const userList = [ {name:"jonh" ,id:EAD1234}, {name:"peter" ,id:EAD1235}, {name:"matt" ,id:EAD1236}, {name:"henry" ,id:EAD1237}, ] In the array above, there are various users with their respective IDs. The goal is t ...

Using useState as props in typescript

Let's imagine a situation where I have a main component with two smaller components: const MainComponent = () => { const [myValue, setMyValue] = useState(false) return ( <> <ChildComponent1 value={myValue} setValue={set ...

Whenever I attempt to run 'npx create-react-app', it keeps throwing an error saying 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'

My attempt at creating a React app was by using the following commands: npx create-react-app my-app However, I encountered an error message: UNABLE_TO_GET_ISSUER_CERT_LOCALLY. I also tried using this command: npm init react-app my-app ...

The state will update after two clicks, and the useEffect hook is not functioning as expected

I have a simple React website template with a button that connects to the Metamask wallet and displays the current balance. One issue I'm facing is that the 'addressBalance' state only updates after the second click on the connect wallet bu ...

What is the proper way to handle a change in state within Redux and trigger a new action using dispatch

Would greatly appreciate guidance on implementing the following functionality with react-redux: Component A triggers an action that makes changes to the state (asynchronous) Component B (not a direct child of A) needs to be able to observe when the state ...

NPM encountered an issue while attempting to perform the installation

Having some issues with NPM while trying to install various apps. The errors that I am encountering are outlined below: npm ERR! Darwin 14.5.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "ember-cli" npm ERR! node v4.0.0 npm ...